17

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.

stackich
  • 3,607
  • 3
  • 17
  • 41
Mukesh2421
  • 191
  • 1
  • 6
  • There's slight confusion with the terminology. Mirroring is something that happens automatically when user selects an Airplay output device using system controls. AirPlay mirroring shows on remote display exactly the same that you see on the device. – Leon Deriglazov May 07 '14 at 17:32
  • @LeontyDeriglazov we can show different different views to external device and our iPhone. But I can not do it from my App while I can do it from iOS control panel. – Mukesh2421 May 20 '14 at 10:41
  • I have seen youtube app and Photo(iOS Native app). We can enable screen mirroring from app. How can I do the same? – Mukesh2421 May 20 '14 at 10:43
  • • YouTube plays a video and Apple supports this use case with MPVolumeView (refer to this answer: http://stackoverflow.com/questions/5730973/airplay-support-mpmovieplayercontroller-and-mpvolumeview-relation) – Leon Deriglazov May 20 '14 at 17:20
  • • As you might guess Apple does not always play by its App Store rules with their apps. You are most likely not getting the same level of control over AirPlay using any public method. – Leon Deriglazov May 20 '14 at 17:23

4 Answers4

1

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.

Leon Deriglazov
  • 1,132
  • 9
  • 13
0

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 an UIImageView into that 2nd UIWindow.

plu
  • 1,321
  • 10
  • 14
  • Thanks for response @plu. I have created UI for second screen. It is working if I switch on screen mirroring from control panel. But it not working when I tap on Apple Tv in available screens within my app. I am showing available screen using MPVolumeView. – Mukesh2421 May 01 '14 at 12:52
0

You can screen mirroring within the app using AVPlayer property.

That property is

@property (nonatomic) BOOL usesAirPlayVideoWhileAirPlayScreenIsActive NS_DEPRECATED_IOS(5_0, 6_0);

or

@property (nonatomic) BOOL usesExternalPlaybackWhileExternalScreenIsActive NS_AVAILABLE_IOS(6_0);.

The default value of usesAirPlayVideoWhileAirPlayScreenIsActive and usesExternalPlaybackWhileExternalScreenIsActive is NO.

usesAirPlayVideoWhileAirPlayScreenIsActive is no effect if allowsAirPlayVideo is NO.

And usesExternalPlaybackWhileExternalScreenIsActive is no effiect if allowsExternalPlayback is NO.

slavoo
  • 5,798
  • 64
  • 37
  • 39
0

You will need to listen for the screen connection/disconnection notifications:

NSNotificationCenter *center = [NSNotificationCenter defaultCenter];

[center addObserver:self selector:@selector(handleScreenDidConnectNotification:)
               name:UIScreenDidConnectNotification object:nil];
[center addObserver:self selector:@selector(handleScreenDidDisconnectNotification:)
               name:UIScreenDidDisconnectNotification object:nil];

In the name:UIScreenDidConnectNotification you will see that your device now has 2 screens and you can do your setup.

Tupps
  • 1