JWPlayerStateDelegate

@objc
public protocol JWPlayerStateDelegate

This delegate reports events based on the player’s state.

Play Events

A handful of different events are reported when a play event is happening. These events happen in this order:

  • isAttemptingToPlay
  • willPlayWithReason
  • isPlayingWithReason
  • Reports when the content is about to complete.

    Note

    Analagous to the onBeforeComplete event in version 3.x.

    Declaration

    Swift

    func jwplayerContentWillComplete(_ player: JWPlayer)

    Parameters

    player

    The player emitting the event.

  • Reports when the content will begin playing.

    Note

    Analagous to the onBeforePlay event in version 3.x.

    Declaration

    Swift

    func jwplayer(_ player: JWPlayer, willPlayWithReason reason: JWPlayReason)

    Parameters

    player

    The player emitting the event.

    reason

    The reason play will begin.

  • Reports when the player is buffering.

    Note

    Analagous to the onBuffer event in version 3.x.

    Declaration

    Swift

    func jwplayer(_ player: JWPlayer, isBufferingWithReason reason: JWBufferReason)

    Parameters

    player

    The player that is buffering.

    reason

    The reason the player is buffering.

  • Reports when the content is buffering.

    Note

    Analagous to the onBuffer event in version 3.x.

    Declaration

    Swift

    @available(*, deprecated, message: "Instead use jwplayer(_ player: JWPlayer, isBufferingWithReason reason: JWBufferReason﹚")
    func jwplayerContentIsBuffering(_ player: JWPlayer)

    Parameters

    player

    The player emitting the event.

  • Reports when additional data has been added to the buffer.

    Note

    Analagous to the onBufferChange event in version 3.x.

    Declaration

    Swift

    func jwplayer(_ player: JWPlayer, updatedBuffer percent: Double, position time: JWTimeData)

    Parameters

    player

    The player emitting the event.

    percent

    Percentage of the media which is currently buffered.

    time

    The current position in the media file.

  • Reports when the content is complete.

    Note

    Analagous to the onComplete event in version 3.x.

    Declaration

    Swift

    func jwplayerContentDidComplete(_ player: JWPlayer)

    Parameters

    player

    The player emitting the event.

  • Reports when the content has finished loading.

    Note

    Analagous to the onFirstFrame event in version 3.x.

    Declaration

    Swift

    func jwplayer(_ player: JWPlayer, didFinishLoadingWithTime loadTime: TimeInterval)

    Parameters

    player

    The player emitting the event.

    loadTime

    The amount of time (in seconds) it took for the player to transition from a play attempt to a firstFrame event.

  • Reports when the content has begun playing.

    Note

    Analagous to the onPlay event in version 3.x.

    Declaration

    Swift

    func jwplayer(_ player: JWPlayer, isPlayingWithReason reason: JWPlayReason)

    Parameters

    player

    The player emitting the event.

    reason

    The reason play has begun.

  • Reports when the player is about to play content.

    Note

    Analagous to the onPlayAttempt event in version 3.x.

    Declaration

    Swift

    func jwplayer(_ player: JWPlayer, isAttemptingToPlay playlistItem: JWPlayerItem, reason: JWPlayReason)

    Parameters

    player

    The player emitting the event.

    playlistItem

    A description of the playlist item attempting to be played.

    reason

    The reason the player is attempting to play the given item.

  • Reports when the content has paused.

    Note

    Analagous to the onPause event in version 3.x.

    Declaration

    Swift

    func jwplayer(_ player: JWPlayer, didPauseWithReason reason: JWPauseReason)

    Parameters

    player

    The player emitting the event.

    reason

    The reason the player became paused.

  • Reports when the content has become idle and is awaiting a new state or command.

    Note

    Analagous to the onIdle event in version 3.x.

    Declaration

    Swift

    func jwplayer(_ player: JWPlayer, didBecomeIdleWithReason reason: JWIdleReason)

    Parameters

    player

    The player emitting the event.

    reason

    The reason the player became idle.

  • Reports when the player has become visible or not visible.

    When the player is 50% or more on the screen, it is reported as visible. If it is less, the player is reported as not visible. This event only reports when this status has changed.

    Note

    Analagous to the onViewable event in version 3.x.

    Declaration

    Swift

    func jwplayer(_ player: JWPlayer, isVisible: Bool)

    Parameters

    player

    The player emitting the event.

    isVisible

    True, if the player is visible. False if it is not.

  • Reports when a new playlist has been loaded into the player.

    Note

    Analagous to the onPlaylist event in version 3.x.

    Declaration

    Swift

    func jwplayer(_ player: JWPlayer, didLoadPlaylist playlist: [JWPlayerItem])

    Parameters

    player

    The player emitting the event.

    playlist

    An array of playlist items in the playlist, in playlist order.

  • Reports when a new playlist has been loaded into the player.

    Note

    Analagous to the onPlaylistItem event in version 3.x.

    Declaration

    Swift

    func jwplayer(_ player: JWPlayer, didLoadPlaylistItem item: JWPlayerItem, at index: UInt)

    Parameters

    player

    The player emitting the event.

    item

    The playlist item that has been loaded into the player.

    index

    The index the playlist item in the playlist.

  • Reports when the entirety of the current playlist has finished playing.

    Note

    Analagous to the onPlaylistComplete event in version 3.x.

    Declaration

    Swift

    func jwplayerPlaylistHasCompleted(_ player: JWPlayer)

    Parameters

    player

    The player emitting the event.

  • Reports when type of media has been loaded.

    Declaration

    Swift

    func jwplayer(_ player: JWPlayer, usesMediaType type: JWMediaType)

    Parameters

    player

    The player emitting the event.

    type

    The type of media content being played.

  • Reports when content playback resumes after seeking.

    Note

    Analagous to the onSeeked event in version 3.x.

    Declaration

    Swift

    func jwplayer(_ player: JWPlayer, seekedFrom oldPosition: TimeInterval, to newPosition: TimeInterval)

    Parameters

    player

    The player emitting the event.

    oldPosition

    The position, in seconds, when seeking began.

    newPosition

    The position, in seconds, requested to be seeked to.

  • Reports when content playback resumes after seeking.

    Note

    Analagous to the onSeeked event in version 3.x.

    Declaration

    Swift

    func jwplayerHasSeeked(_ player: JWPlayer)

    Parameters

    player

    The player emitting the event.

  • Reports a change in the playback rate.

    This method reports when the playback rate has changed, excluding when the rate has changed due to play beginning, or pausing. To listen for state changes in the player, such as play or pause, conform to the JWPlaybackStateDelegate

    Note

    Analagous to the onPlaybackRateChanged event in version 3.x.

    Declaration

    Swift

    func jwplayer(_ player: JWPlayer, playbackRateChangedTo rate: Double, at time: TimeInterval)

    Parameters

    player

    The player emitting the event.

    rate

    The new playback rate.

    time

    The position in the content, expressed in seconds, at which the playback rate changed.

  • Reports when the cue points have been updated.

    Declaration

    Swift

    func jwplayer(_ player: JWPlayer, updatedCues cues: [JWCue])

    Parameters

    player

    The player emitting the event.

    cues

    The new list of cues.