I have implement the MPVolumeView to show Airplay option but I don't know how to hide MPVolumeView if Airplay options/sources are no longer available.
Is there any public API which can detecting AirPlay option/source are available or not. So that application can hide/show the airplay option.
NOTE: I am using custom player not the default MPMoviePlayerController
Thanks!
I see two approaches that would work:
Add observer for MPVolumeViewWirelessRoutesAvailableDidChangeNotification and hide or remove your subview.
- (void)viewWillAppear:(BOOL)animated {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleWirelessRoutesDidChange:)
name:MPVolumeViewWirelessRoutesAvailableDidChangeNotification object:nil];
}
- (void)viewWillDisappear:(BOOL)animated {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)handleWirelessRoutesDidChange:(NSNotification *)notification {
NSLog(@"Wireless routes did change: %@", notification);
// Hide or remove your MPVolumeView
}