Reputation: 715
I would like to open iOS' native audio destination picker UI inside of my application (pictured below). Is there a way to do this with AVAudioSession
?
Upvotes: 5
Views: 2388
Reputation: 715
This is the control I was looking for: https://developer.apple.com/documentation/avkit/avroutepickerview. It appears on screen as a button (with the default AirPlay 2 icon) and handles all of the logic for you.
Example
import AVKit
let audioPicker = AVRoutePickerView(frame: ...)
addSubview(audioPicker)
You can subscribe to audio route updates with the following:
NotificationCenter.default.addObserver(self, selector: ...), name: AVAudioSession.routeChangeNotification, object: nil)
Upvotes: 10