Question

Is anyone still getting, with iOS 5, screen connect/disconnect notifications, regardless of whether you check mirroring or not? I don't seem to be getting any notifications, unless I plug a video-out cable to my device, instead of using AirPlay.

I have an AirPlay button in my app, provided by MPVolumeView. I can tap it and select an Apple TV. The AirPlay button turns blue. I get no notification.

I can go to the "Now Playing" screen (double-click and page to one end), and select an Apple TV. I get confirmation as the AirPlay icon turns blue. My app gets no confirmation (even after returning to it).

I can go to the "Now Playing" screen (double-click and page to one end), and select an Apple TV AND select mirroring. I get confirmation as the AirPlay icon turns blue. My app gets no confirmation (even after returning to it).

I quit my app, I leave mirroring on. I restart my app. I have code that checks for the number of screens. I only see one.

I am hoping I am doing something wrong, but I want to check and make sure others out there are getting notifications when using AirPlay. I recall having tested my AirPlay compatibility during the 5.0 betas, and not having had these issues.

(Apple's ExternalDisplay sample is behaving the same way.)

Code I use for notification registration:

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(screenDidConnect:)
                                             name:UIScreenDidConnectNotification
                                         object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(screenDidConnect:)
                                             name:UIScreenDidDisconnectNotification 
                                           object:nil];

Code the notifications should call:

- (void) screenDidConnect:(NSNotification *)notification {
    if ([[UIScreen screens] count] > 1) 
        [self myScreenInit:[notification object]];
    else {
         ...
    }
Was it helpful?

Solution

Turns out that as of iOS 5.0 you only get notification, in the following cases:

  • iPad 2 or iPhone 4s and
  • you have to turn mirroring on in the "Now Playing" screen of the device (tap home button twice, go to the leftmost page, tap on the AirPlay icon, select an AppleTV and turn on mirroring). This seems odd, but that's the way it works. Just selecting an AirPlay AppleTV without mirroring let's you use the AppleTV for content that is displayed within AVPlayer's framework.

With an HDMI cable, more devices can utilize a second screen using UIScreen.

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