SRGSSR / srgmediaplayer-apple

An advanced media player library, simple and reliable
MIT License
159 stars 33 forks source link

Interstitial Implementation #48

Closed tooolbox closed 6 years ago

tooolbox commented 6 years ago

Issue overview

AVPlayerViewController offers a feature for interstitial content, whereby you can mark certain time ranges in your content. A delegate object will then be notified when the player hits those ranges, and this can be used to halt scrubbing and/or disable player controls. This feature is covered here in the documentation, and is currently only available for tvOS.

Interstitial Content. Some content might be unrelated to the main content presented in your player view controller, or have different presentation requirements. For example, you might not allow the user to skip over advertisements when scrubbing through the playback timeline, or require that the user not skip mandatory legal notices.

Use the AVInterstitialTimeRange class to describe interstitial content, and the interstitialTimeRanges property to associate those time ranges with the AVPlayerItem object presented in the player view controller. Then, you can use the player view controller’s delegate object to be notified when interstitial content plays, and change playback options such as the requiresLinearPlayback property accordingly.

You guys have something called "segments", which I don't fully understand and haven't seen in any other players, and you can "block" them and so forth. At first I thought this might be your own terminology or solution for the subject of interstitials, but after reviewing the methods it doesn't seem related.

Couple questions and points:

Check the correct option below

tooolbox commented 6 years ago

You know...it's possible that this could be implemented with segments, at least to a degree. It seems like you can define segments, and the player fires a notification when it enters a segment...would have to figure out scrubbing, but seems like a start.

defagos commented 6 years ago

We haven't discussed or decided yet whether the concept of interstitial content should natively be supported by our library, as we currently do for blocked media regions.

But since segments provide a way to add a logical structure to a media, you should be able to use them to implement the behavior you need.

Any suggestions on the best way to go about this, architecturally?

I would attempt defining segments matching your interstitials, then respond appropriately within them. In your case I would probably register a periodic time observer (addPeriodicTimeObserverForInterval:queue:usingBlock:), which would check whether a segment is currently played (currentSegment), and disable controls appropriately.

Would you be interested in this as a contribution to your library?

We could of course be interested in having this functionality built-in, and we are open to contributions as well.

Would I need to write it in Objective-C to contribute it to your library?

Yes, for technical reasons we distribute our libraries only in Objective-C at the moment.

defagos commented 6 years ago

This feature is not planned at the moment. Segments can be used instead.