PlaybackPolicyHandler
public protocol PlaybackPolicyHandler : AnyObject
Playback Policy Handler.
-
The player instance
Note
Mark this property as week in the implementation to avoid retain cycle. Don’t use the instace to seek. Ex: player.seek(to: Timeinterval).Declaration
Swift
var player: Player? { get set } -
The
AdPlaybackPolicyinformation.Declaration
Swift
var adPlaybackPolicy: AdPlaybackPolicy? { get } -
This function is called when the application become background.
Declaration
Swift
func applicationDidEnterBackground() -
This function called when the player is interrupted. Ex: phone call, etc.
Declaration
Swift
func playbackDidInterrupt() -
This function called when client app set preference to the player for starting from bookmark position. Find the Initial playback time according to the policy and return the playhead positin where the player should start playback.
Declaration
Swift
func resolveSeekIntentForInitialPlayback(position: TimeInterval) -> TimeIntervalParameters
positionThe playhead position that the user wishes
Return Value
The absolute playhead position in seconds.
-
Solicits to seek to the desired time position. This is just providing the player’s seek position intent since the real seek position needs to be determined by the ad playback rules (a.k.a. scrub management policies). For example: A user may scrub over one/several Ad Breaks but on resume of the video play:
- The user will see the last Ad Break before the content will resume.
- The playback will resume at the point the user dropped the scrubber.
In the example above the
AdPlaybackPolicyprovider will need to callPlayer.seektwice. The first call is to seek to the beginning of the Ad Break and the second call, after the Advert Break is played out, is to the user specified seek position.Note
This API should only be consumed by the
AdPlayerimplementation that integrates withAdPlaybackPolicyprovider.Declaration
Swift
func resolveSeekIntent(position: TimeInterval) -> TimeIntervalParameters
positionThe playhead position that the user wishes to seek to, in seconds.
Return Value
The absolute playhead position in seconds.
-
Determines if the policy want to auto seek to particular adBreak start/ bookmark positon on adBreakEnd. Return the value of the seek position where the player should continue playing after the adBreak end. If there is no seek required the return nil. This function is called on every adBreakEnd and adBreak skip events Also on resuming the playback.
Declaration
Swift
func getAutoSeekPositionIfAny() -> TimeInterval?Return Value
The absolute playhead position in seconds.
-
Determines a relative content playhead position, discounting the sum of all ad break durations prior to the absolute playhead position provided. This allows the client to return to the same content position if a VOD stream is stopped before playback ends.
Declaration
Swift
func getContentPositionForPlayhead(playhead: TimeInterval) -> TimeIntervalParameters
playheadThe absolute playhead position, in seconds.
Return Value
The relative content position in seconds.
-
Determines an absolute playhead position calculating the sum of all ad break durations prior to that absolute playhead position plus the relative content playhead position. This allows the client to return to the same content position if a VOD stream is stopped before playback ends.
Declaration
Swift
func getPlayheadForContentPosition(position: TimeInterval) -> TimeIntervalParameters
positionThe relative content position, in seconds.
Return Value
The absolute playhead position in seconds.
-
Determines a content duration calculating the sum of all ad break durations discounting from the overall duration.
Declaration
Swift
func getContentDuration() -> TimeIntervalReturn Value
The relative content duration in seconds.
-
Determines if the policy want to skip to particular AdBreak on play api.
If the application has added
PlaybackRepeatedRule.REPEAT_PLAY_ONCEto theAdPlaybackPolicy, anAdBreakthat has already been played will be restricted from playing again, and the end position of the already playedAdBreakwill be returned.Declaration
Swift
func getInterruptedPositionIfAny() -> TimeInterval?Return Value
The absolute playhead position in seconds.
-
Get the list of watched ad breaks. An ad break is considered watched if the ad break has started and either completed or skipped.
Declaration
Swift
func getWatchedAdBreaks() -> [AdBreak]?Return Value
Array of watched ad breaks if any.