I am using MPVolumeView
to show AirPlay
button. I need to show a custom wallpaper to Apple
TV
through mirroring with audio. Audio is playing properly on Apple
TV
but wallpaper image is not showing. I am using AVAudioController
for playing audio. I have checked YouTube
application in which screen mirroring is working from application for video playing. Is it possible to screen mirroring within the app using AVAudioController
?
Help me to solve this issue. Thanks in advance.
You can screen mirroring within the app using AVPlayer property.
That property is
or
The default value of
usesAirPlayVideoWhileAirPlayScreenIsActive
andusesExternalPlaybackWhileExternalScreenIsActive
is NO.usesAirPlayVideoWhileAirPlayScreenIsActive
is no effect ifallowsAirPlayVideo
is NO.And
usesExternalPlaybackWhileExternalScreenIsActive
is no effiect ifallowsExternalPlayback
is NO.You will need to listen for the screen connection/disconnection notifications:
In the name:UIScreenDidConnectNotification you will see that your device now has 2 screens and you can do your setup.
Unfortunately, external display associated with AirPlay will only become active (and post appropriate notification) when you enable AirPlay mirroring in control panel. There appears to be no way to enable mirroring programmatically.
MPVolumeView can help user redirect audio to AirPlay speakers, it has nothing to do with display mirroring.
You can find the documentation here: https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/WindowAndScreenGuide/UsingExternalDisplay/UsingExternalDisplay.html
Basically it's about creating a 2nd
UIWindow
, if an external display is available. There you can show your wallpaper, which is an image, I assume. Should be simple to put that via anUIImageView
into that 2ndUIWindow
.