Player

The primary player interface

  • Undocumented

    Declaration

    Swift

    var delegate: PlayerDelegate? { get set }
  • API to add a block to be executed before player load.

    If the block is async and fails to return before player load which is also a async operation, it is possible that this block might be executed after player load. It is entirely the responsibility of a block to be sync so that it is executed before player load.

    Declaration

    Swift

    func addPreloadBlock(block: @escaping (Player) -> Void)

    Parameters

    block

    A closure accepting Player as input

  • API to add a block to be executed on player state change.

    Declaration

    Swift

    func addStateChangeBlock(block: @escaping (Player) -> Void)

    Parameters

    block

    A closure accepting Player as input

  • API to add a block to be executed on heart beat or playback progress every second.

    Declaration

    Swift

    func addHeartBeatBlock(block: @escaping (Player) -> Void)

    Parameters

    block

    A closure accepting Player as input

  • API to add multiple delegates to listen playback events

    Declaration

    Swift

    func addDelegate(_ delegate: PlayerDelegate)
  • API to remove delegates that were added using addDelegate function

    Declaration

    Swift

    func removeDelegate(_ delegate: PlayerDelegate)
  • API to add boundary time to observe on linear progress

    Declaration

    Swift

    func addPlayheadBoundaryObserver(positions: [TimeInterval], leadTimeMs: TimeInterval, callback: @escaping (TimeInterval) -> Void) -> PlayheadBoundaryObserverToken?

    Parameters

    positions

    Positions respective to stream time of the player

    leadTimeMs

    Earliest lead time interval to trigger before position.

    callback

    Callback action for fireing the observed positions.

    Return Value

    return the BoundaryObserverToken

  • API to remove boundary observer token added using addPlayheadBoundaryObserver

    Declaration

    Swift

    func removePlayheadBoundaryObserver(token: PlayheadBoundaryObserverToken)
  • API to invoke when the application received AVPlayerViewControllerDelegate callbacks for playback.

  • Updating player current positions to the MPRemoteCommandCenter

    Declaration

    Swift

    func updatePlayPostionInControlCenter(duration: Double, rate: Float, currentTime: Double, isLive: Bool)

    Parameters

    duration

    Total duration of the player content

    rate

    Player rate position play/pause (1 or 0)

    currentTime

    Player current time position

  • API to add boundary time to observe on linear progress

    Declaration

    Swift

    func addPlayheadBoundaryObserver(positions: [TimeInterval], callback: @escaping (TimeInterval) -> Void) -> PlayheadBoundaryObserverToken?

    Parameters

    positions

    Positions respective to content player

    callback

    Callback action for fireing the observed positions.

    Return Value

    return instance of the boundary observer