I have a video application in which I am using Airplay to stream the video. I am using the below code.
let airView: MPVolumeView = MPVolumeView()
airView.showsRouteButton = true
airView.showsVolumeSlider = true
airView.sizeToFit()
airView.tintColor = UIColor.black
airView.autoresizingMask = UIViewAutoresizing.flexibleWidth
airplayButton = UIBarButtonItem(customView: airView)
airplayButton.tintColor = UIColor.white
self.navigationItem.setRightBarButtonItems([airplayButton], animated: true)
Using the code below, I can see the Airplay picker button, I can also see the volume slider however when I am connecting the airplay, the volume button disappears so our clients can not make volume up and down using the phone hardware button.
Is there a way to have either to prevent the disappearance of that button or support hardware volume support while playing Airplay?
Additional info:
When using older AirPlay devices such as an old AppleTV that users AirPlay1 the volume controls should work. However, when the same app is connected to an AirPlay2 device, the volume controls are removed. And in fact the data screen for the MPVolumeSlider is removed. The slider will return when connected back to the Phone or Bluetooth speakers.
Recently Apple deprecated the Router Button on MPVolumeView starting with iOS 13 and this new router view does not include a volume slider. It appears that Apple wants us to use either the rocker, airplay mirroring or the volume controls that the AVRouterView holds. This change becomes very confusing to the user as sometimes the slider is there and sometimes it isn't. Even if the slider is shown disabled with another slider, the user does not understand why they can use the rocker and sliders in the AVRouterView and not on the app itself with AirPlay2. They also don't even understand what AirPlay1 vs AirPlay2. Things such as metadata even work differently.
Related
I have an application for video streaming. It has ability to make mirroring AirPlay (Apple Tv). Now I'm trying to add Google Chromecast connection. I added button and everything working just I expected. Here is my case: I want user only be able to connect 1 device at the moment. For example if user already conneceted to AirPlay when user tap on Chromecast, I want to disable AirPlay programmatically.
Here's how I checked external playback status:
self.videoPlayer.isExternalPlaybackActive
Here's how I checked is AirPlay connected:
- (BOOL)isAirPlayConnected {
return self.airPlayButton.isWirelessRouteActive;
}
I know this is how I disabled all external display:
self.videoPlayer.allowsExternalPlayback = NO;
self.videoPlayer.usesExternalPlaybackWhileExternalScreenIsActive = NO;
I already listening:
MPVolumeViewWirelessRoutesAvailableDidChangeNotification and MPVolumeViewWirelessRouteActiveDidChangeNotification notifications.
Bu couldn't find solution for programatically disconnect before switching the other.
Any help would be appreciated.
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
When the user selects to use AirPlay, the MPVolumeView removes the volume slider and only shows the AirPlay, which is what is expected.
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.
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.
I've got an instance of AVPlayer which plays some media, but I don't want user to be able to stream it via AirPlay. So I set allowsExternalPlayback property of AVPlayer to NO. However it doesn't seem to affect AirPlay button in control center, so it stays visible. Is there any way to hide the button?
Hi i am building iOS application target iOS 5 and above. I am using MPMoviePlayerController to stream movie file. I that player i want to give airplay support.
According to apple documentation
Default Movie players (iOS 4.3 and later) support wireless movie
playback to AirPlay-enabled hardware such as Apple TV. The movie
player presents a control that allows the user to choose
AirPlay-enabled hardware for playback when such hardware is in range.
It seems that by default it will display airplay button in fullscreen mode if any airplay device is in range. But it is not seems to be happening. I am unable to see airplay button in movie player.
Am i missing something? Please advise.
By default, MPMoviePlayerController enables AirPlay support. If you haven't set it as FALSE. Then, probably you need to check your network or AppleTV's network connection. They need to be in same network (intranet usually).
There is a safe way to detect whether your iOS device is able to find AppleTV. You can double click HOME button, swipe task bar from left to right side, if you can see "Airplay" route button, then you can reach it. Otherwise, you need to check your AppleTV setting to make sure Airplay function is enabled and AppleTV is connected to same network that you iOS device in.
If you are using your own customized video play controller interface, you can embedded the "Airplay" button into your own UI.
MPVolumeView
I am developing an iOS app that displays a video, e.g., a football game, on Apple TV via AirPlay. I want to display additional information, e.g., player stats, on the big screen while the video is playing.
I am aware of the Redfin approach, where they require the user to turn on AirPlay mirroring first. Unfortunately, this is not acceptable for us. We want it to be obvious to users on how to show the video.
We are currently presenting an AirPlay Route button before displaying the video to allow the user to set it up using the following code.
self.airPlayPicker = [[MPVolumeView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
self.airPlayPicker.showsVolumeSlider = NO;
self.airPlayPicker.showsRouteButton = YES;
[self.view addSubview:self.airPlayPicker];
The Route button will show when there is an Apple TV around, allowing the user to turn it on. We then present the video with MPMoviePlayerController.
When AirPlay is turned on and the video is playing, in code, I see only one UIScreen, but two UIWindows. But both UIWindows have the same dimensions as the iPhone. When I add a subview to either UIWindow, the subview always shows up on the iPhone.
Has anyone figured out how to present an overlay on top of the video on Apple TV? How do I even find the view object where the video is hosted?
I am aware that MPMoviePlayerController is built on top of AVPlayer. Would using AVPlayer give us better control of the UI?
As far as I know, this shouldn't be possible. When using AirPlay without mirroring, only the URL of the video is sent to the Apple TV. It is then up to the Apple TV to actually play the media.
Mirroring is the way to do it.