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
?
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With