MPVolumeView Airplay Button Disappears - ios

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.

Related

UIWebView Keep Video Playing After Exiting Fullscreen

In our app, we want to be able to keep a video playing after the user has quit fullscreen mode. The video is a YouTube one, thus it uses YTPlayerView framework, which uses UIWebView and iframe player to play the video.
As you have probably noticed, in iOS 11, when a web video enters fullscreen, there is only one 'X' button at the upper left corner to quit fullscreen and pause the video, instead of two(one 'Done' at the top and one arrow at the bottom) like before.
I have been able to get a UIWindowDidBecomeHidden notification when the fullscreen quits, and play the video programmatically, but then I realize that if the user has already paused the video manually before quitting fullscreen, it will start playing nonetheless when he/she quits. However, adding something in the YTPlayerDelegate won't do much since the system will pause the video(sending the stateDidChange delegate) before sending the notification, so I cannot differentiate between a manual pause when fullscreen and a system pause when quitting fullscreen.
My question is, is there a way to detect leaving fullscreen action before the system pauses the video? If not, is there a native API to have the player keep playing? If not either, is this feature possible? How would I achieve it? Thanks.

Using the 'YouTube-Player-iOS-Helper', is it possible to not pause playback when removing the YTPlayerView from the screen?

I am developing a music app that plays audio, regular video (such as mp4) and youtube videos. It has the proper background mode enabled, as the app plays audio and regular video correctly in the background.
The following issue appears only on the iPad, not on the iPhone.
Using the YouTube-Player-iOS-Helper on iOS 8, adding the youtube video content (YTPlayerView) to another view (as a subview) works great, even when playing. However, removing that YTPlayerView from its superview automatically pauses the playback, which isn't always the desired case (sending the app to the background causes the same effect).
Is it possible to change that behaviour?
I can rationalize manually resuming the playback when the app goes to the background, however, doing the same for the 'remove from superview scenario' causes the playback to stutter for a moment.
The issue can easily be reproduced with the sample app for 'YouTube-Player-iOS-Helper', by playing a video and then changing between tabs. On the iPhone, the player does NOT pause, but on the iPad, the player DOES pause.
If it's impossible, is there other Youtube SDKs that allow this behaviour and still adhere to the official terms and conditions?
Thanks
Figured this one.
The YTPlayerView will NOT pause, on iPad or iPhone, if you remove it from its superview and immediately add it to a view again (can be a different view). That view must be inside a view controller properly rooted in the view hierarchy (not detached).

AVPlayer: AirPlay button shows up in control center even though allowsExternalPlayback is set to NO

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?

Show airplay/route button on default video player in iOS

Why is it so difficult to show the airplay button in the default video player? Why isn't there a simple on/off switch? My app has a webview in place and videos that open through the webview open the default video player with no airplay button.
I tried using MPVolumeView and got the button to display in a view, but I cannot figure out how to show it in the place it normally should show, see image: http://i.stack.imgur.com/0xdoo.jpg

AVPlayerLayer video is not visible

I have an iOS APP, which can play videos.
It can play background.
When app will resign active, i remove the AVPlayerLayer, so the sound will go on.
And when app did become active, i attach the layer again, so the video come back.
All works well at iOS8 and iOS7.But....
Only when my player viewcontroller is not visible, i resign my app, and then come back and present my player viewcontroller, the video disappear (Only iOS7, iOS8 also works well)
anyone know about it?

Resources