AirPlay mirroring with AVPlayerViewController - I want to mirror the entire primary window

I have an app that plays video in an AVPlayerViewController that also has some overlays on it.


I'd like to be able to mirror the entire app, but when I attempt this, only the video displayed in the AVPlayerViewController AirPlays, while the rest of the UI (including the overlays) remains on the iOS device.


Short of basically reworking the mirroring functionality manually via the Multiple Display Mirroring Guide (using UIScreenDidConnectNotification & UIScreenDidDisconnectNotification and mirroring the second screen), is there any way for me to make mirroring work in full with the AVPlayerViewController on screen?

Replies

The method that you describe (using screen connection notifications and establishing a second window on the second UIScreen) is the recommended path for achieving what you are trying to do. Basic AirPlay video playback does not allow for the addition of any UI elements on the secondary screen.

Hello TidBits,


Your answers also caught my interest as I am trying to do similar things. Basically, what I want is to display some overlay image on top of video, like a image logo with transpeancy alpha channel. This can be done easily on the phone. However, when video is casted on AirPlay and when the property of AVPlayer "usesExternalPlaybackWhileExternalScreenIsActive" is set to true, it seems that I cannot place any other view on the secondary screen.


You said "Basic AirPlay video playback does not allow for the addition of any UI elements on the secondary screen.". So if I really want to have this feature implemented, is there any possbility and what can you suggest?

The only way would be to add a window to the second UIScreen, which would then allow you to put the video player layer on that second screen and overlay visual elements on top.


However, we'd not recommend this as it is likely to impact video quality, and also would prevent users from making use of their phone during video playback. Playback would stop as soon as the device goes to sleep or the app goes into the background.


We would ask that you request this feature and capability as part of AirPlay video at bugreporter.apple.com

Hello TidBits,


Thank you very much for your reply.


I have tried the approach you proposed, by adding a window and video player layer and overlay layer to the second UIScreen. However, this approach does not seem to work when the property usesExternalPlaybackWhileExternalScreenIsActive of AVPlayer is set to true. And I need this feature to be enabled because I am dealing with FairPlay streaming so usesExternalPlaybackWhileExternalScreenIsActive must be enabled in order to cast video playback to external device.


Can you please confirm that, when usesExternalPlaybackWhileExternalScreenIsActive is enabled or when AVPlayerViewController is used, AirPlay does not allow for any additional UI elements on the secondary screen? If this is the case, I will try to report to bugreporter.apple.com.

Your summary is correct. The workaround I described (and also don't really recommend) does not work for contetn protected with FPS.