iOS 9.1 - iPhone 6S
The MPVolumeView (airplay) route button does not appear when the application starts, even if there are wireless routes available.
I tried to request my MPVolumeView after it was created for checking wireless routes, and I get 0. I can only get 1 (and show the route button) by disabling and allowing WiFi to trigger a notification.
MPVolumeView in my application is designed to control the volume of videos played in UIWebView. Also, whenever I activate the wireless route for streaming, the MPVolumeView slider disappears - is there a way to prevent this behavior when using UIWebView to play media?
Below is my code for creating MPVolumeView:
-(void) createAndDisplayMPVolumeView{ // Create a simple holding UIView and give it a frame volumeHolder = [[UIView alloc] initWithFrame: volumeSlider.frame]; volumeHolder.autoresizingMask = UIViewAutoresizingFlexibleHeight; volumeSlider.hidden = YES; // set the UIView backgroundColor to clear. [volumeHolder setBackgroundColor: [UIColor clearColor]]; // add the holding view as a subView of the main view [nowPlayingMainView addSubview: volumeHolder]; // Create an instance of MPVolumeView and give it a frame myVolumeView = [[CustomVolumeView alloc] initWithFrame: volumeHolder.bounds]; myVolumeView.tintColor = [UIColor darkTextColor]; myVolumeView.showsRouteButton = YES; myVolumeView.showsVolumeSlider = YES; volumeRect = myVolumeView.frame; [myVolumeView setRouteButtonImage:[UIImage imageNamed:@"airplayButton"] forState:UIControlStateNormal]; [myVolumeView setRouteButtonImage:[UIImage imageNamed:@"airplayButtonHighlighted"] forState:UIControlStateHighlighted]; [myVolumeView setRouteButtonImage:[UIImage imageNamed:@"airplayButtonSelected"] forState:UIControlStateSelected]; [volumeHolder addSubview: myVolumeView]; }
ios xcode airplay mpvolumeview
Elliott malone
source share