Hi all,
I am trying to understand how to show the AirPlay menu in SwiftUI. My goal is to show the AirPlay menu, the same one displayed in the music app, but programmatically from a SwiftUI Button.
I was able to display the AirPlay menu using UIViewRepresentable and MPVolumeView, but that does not show the currently active AirPlay speakers (no checkmarks).
So how can I:
- Show the AirPlay button from a custom SwiftUI button?
- Show the same AirPlay menu as the one in the Music app, with preselected active speaker?
Hello @ashinthetray,
As you just found, Media Player's MPVolumeView isn't exactly what you're looking for.
The correct API to display an AirPlay menu similar to the one in the Music app is actually AVRoutePickerView in AVKit.
I hope this helps.
Best regards,