6

I have an app that displays videos, and it's very important to us that we intercept all pause events, and prevent users from seeking in videos.

Doing it on device is pretty simple, we just don't expose any 'regular' controls to user, and in -remoteControlReceivedWithEvent:, we wrap all events that we're actually interested in.

But we're struggling with supporting Apple TV. It's our understanding that it should forward all events sent from Apple Remote to our app, as per [0]:

When AirPlay is in use, your media might be playing in another room from your host device. The AirPlay output device might have its own controls or respond to an Apple remote control. For the best user experience, your app should listen for and respond to remote events, such as play, pause, and fast-forward requests. Enabling remote events also allows your app to respond to the controls on headphones or earbuds that are plugged into the host device.

However, as far as I can see from my debugging and pulled hair, it doesn't apply to cases where you let AVPlayer handle displaying your video. We actually don't do anything at all to make videos play on TV, since AVPlayer's allowsExternalPlayback property is YES by default.

If I'm understanding docs correctly, while using that mode with Apple TV, only URL/data from device is sent to Apple TV, and aTV does the decoding and rendering part on it's own, as per [1]:

External playback mode is when video data is sent to an external device such as Apple TV via AirPlay and the mini-connector-based HDMI/VGA adapters for full screen playback at its original fidelity. AirPlay Video playback is also considered as an "external playback" mode.

which could potentially explain why I don't receive any events on device (e.g. someone at Apple thought that since aTV does the heavy lifting and actually decoding and rendering, apps on device shouldn't receive those events).

So, my question is basically this - is there any obvious tree I'm missing from the forest, or do I have no retreat other than either:

  • ugly hacks using KVO on playback position and playback rate, and punishing users for 'cheating'
  • reimplementing whole video rendering on my own, treating TV screen as second display

Any pointers will be greatly appreciated.

[0] https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/AirPlayGuide/EnrichYourAppforAirPlay/EnrichYourAppforAirPlay.html

[1] https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVPlayer_Class/Chapters/Reference.html#//apple_ref/occ/cl/AVPlayer

Jan Klausa
  • 61
  • 2
  • 2
    If anyone stumbles upon this page while trying to resolve their problem, I submitted an rdar to Apple for this: http://openradar.appspot.com/radar?id=5327082565402624 – Jan Klausa Feb 18 '14 at 14:47
  • Unfortunately, I have no answer to provide, but rather a "hey, me too". There is no way I can grab the events from the controls that appears on my external playback output (that is, a computer screen here, using Reflector). The one thing I noticed is that I get a KVO event over the 'rate' property when the video being played is a _(live)stream_ and not a VOD. That's the best I could do so far. – onekiloparsec Mar 04 '15 at 15:46
  • Any news from this topic ? We are facing the exact same issue. – BoilingLime Feb 07 '17 at 11:39

0 Answers0