Question

I have iOS application that plays video through HTTP via AVPlayer.

I have MPVolumeView that allows to select airplay device to stream current playback to.

But now I need to have ability to programmatically stop video streaming, and continue playback on AVPlayer's video layer in my application on iPad screen. (Like MPVolumeView's button does, but programmatically)

Please, help me, I tried to find solution myself and with the help of google but I am not able to solve this problem:(

Is it really possible?

Thanks!

Was it helpful?

Solution 2

First you'd have to read this reference on programming multiple displays.

But in this specific situation I think, you are looking for [UIScreen screens] which returns an NSArray of UIScreen objects. The UIScreen with index 0 is the internal display and the one with the index 1 is the Apple TV's display. From now on, according to this documentation and its examples you only need to create a UIWindow which has the screen property of the UIScreen you want to display on. Then you can easily add layers, views, etc. to that UIWindow.

OTHER TIPS

In this scenario, you don't need to program multiple displays directly. You just need to tell iOS' video subsystem to stop using the other display...

AVPlayer has a property allowsExternalPlayback which you can set to NO. This will disable playback on the external display. Playback will continue on the player's original AVPlayerLayer within your application.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top