Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable AirPlay with MPMoviePlayerController

I have an instance of a MPMoviePlayerController which is being used to display some live streaming video on an iPhone app. This is working fine, however I wish to remove all AirPlay functionality.

To be sure, I specifically disable AirPlay like so:

if([self.moviePlayerController respondsToSelector:@selector(setAllowsAirPlay:)]) {
    self.moviePlayerController.allowsAirPlay = NO;
}

However, even with this code, I still see the AirPlay icon on the video controls. If I select this, and select my AppleTV, only the audio is sent over AirPlay - the video continues to play within the app. If I set allowsAirPlay to YES, both the video & audio are sent over AirPlay.

Does anyone know why this happens? Is this a feature of the OS, to allows allow the audio to be sent over AirPlay?

like image 986
Ben Williams Avatar asked Oct 13 '11 05:10

Ben Williams


2 Answers

It turns out that the AirPlay icon is still visible (and should remain visible) so that audio can be routed to any suitable device, eg. a Bluetooth headset. Attempting to hide the icon is considered bad practice.

like image 51
Ben Williams Avatar answered Sep 16 '22 15:09

Ben Williams


I known its an old question but still maybe this will help someone else.
Apple has the following api to hide the route button (AirPlay)

@property (nonatomic) BOOL showsRouteButton NS_AVAILABLE_IOS(4_2);  // Default is YES.

Hope this helps anyone.

like image 38
Philip Kramer Avatar answered Sep 17 '22 15:09

Philip Kramer