5

I have created a custom video player in Swift using AVPlayer and am using the MPVolumeView for the volume control as well as AirPlay. The views initialize perfectly, but I am running into a case where the AirPlay button disappears inside the MPVolumeView.

When the view loads, the MPVolumeView is initialized without issues

MPVolumeView Initialization

When the user selects to use AirPlay, the MPVolumeView removes the volume slider and only shows the AirPlay, which is what is expected.

Airplay Enabled

The problem comes when the user closes the UIViewController then opens it again to play another video. The Airplay remains enabled, which is the expected behavior. When the user selects to turn off AirPlay, the video returns to playing on the physical device, but the AirPlay button gets hidden.

Missing AirPlay Button

I have even attempted setting showsRouteButton to true for my MPVolumeView, but that has no effect on this. What could be causing the AirPlay button to be hidden in this case? It only occurs if AirPlay is enabled when the user starts playing a video, then turns off AirPlay.

Rhythmic Fistman
  • 34,352
  • 5
  • 87
  • 159
Mike Walker
  • 2,944
  • 8
  • 30
  • 62

0 Answers0