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 AdPlaybackPolicy information.

    Declaration

    Swift

    var adPlaybackPolicy: AdPlaybackPolicy? { get }
  • This function called as soon as the player knows the AdBreaks information. Capture this adBreak information for evaluating ads.

    Declaration

    Swift

    func set(adBreaks: [AdBreak])
  • 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) -> TimeInterval

    Parameters

    position

    The 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 AdPlaybackPolicy provider will need to call Player.seek twice. 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 AdPlayer implementation that integrates with AdPlaybackPolicy provider.

    Declaration

    Swift

    func resolveSeekIntent(position: TimeInterval) -> TimeInterval

    Parameters

    position

    The 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) -> TimeInterval

    Parameters

    playhead

    The 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) -> TimeInterval

    Parameters

    position

    The 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() -> TimeInterval

    Return 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_ONCE to the AdPlaybackPolicy, an AdBreak that has already been played will be restricted from playing again, and the end position of the already played AdBreak will 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.