Search code examples
iosiphoneairplayuiscreenapple-tv

iOS - Apple TV - Detect show on Apple TV programmatically


How can i detect showing on Apple TV?

I've tried already to detect num of screens:

[[UIScreen screens] count]

But it remains on 1.

I've tried also to listen to an event:

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

But the event never fire.

Any tips/tricks?

Thanks in advance!


Solution

  • Found the answer!

    As simple as it could be:

    Just do:

    self.moviePlayer.isAirPlayVideoActive
    

    It will return me whether the AirPlay is active/not active.

    Thanks @rist