2014-02-06 90 views
2

如何检测Apple TV上的显示?iOS - Apple TV - 以编程方式在Apple TV上检测节目

我试过已经检测屏幕编号:

[[UIScreen screens] count] 

但它仍保留在1

我也试着听的事件:

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

但事件从未开火。

任何提示/技巧?

在此先感谢!

+0

不知道如果我正确地理解你的问题 - 但这是https://stackoverflow.com/questions/9272223/is-there-any-notification-for-detecting-airplay的副本-in-Objective-C的? – rist

+0

不完全,上面的问题/答案谈到检测airPlay可用,这就是全部。我需要检测用户何时真正在AppleTV上播放电影(airPlay)。任何想法? – gran33

+1

所以你有一个MPMMoviePlayerController,用户点击Airplay按钮,它运行在Apple TV上。用户交互的内容和方式可能很难检测到,因为AppleTV完全处理该流(只需断开设备与wifi的连接,您将看到该流仍在运行) – rist

回答

4

找到答案!

简单,因为它可能是:

只要做到:

self.moviePlayer.isAirPlayVideoActive 

它将返回我的AirPlay是否激活/未激活。

感谢@rist