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 theonBeforeCompleteevent in version 3.x.Declaration
Swift
func jwplayerContentWillComplete(_ player: JWPlayer)Parameters
playerThe player emitting the event.
-
Reports when the content will begin playing.
Note
Analagous to theonBeforePlayevent in version 3.x.Declaration
Swift
func jwplayer(_ player: JWPlayer, willPlayWithReason reason: JWPlayReason)Parameters
playerThe player emitting the event.
reasonThe reason play will begin.
-
Reports when the player is buffering.
Declaration
Swift
func jwplayer(_ player: JWPlayer, isBufferingWithReason reason: JWBufferReason)Parameters
playerThe player that is buffering.
reasonThe reason the player is buffering.
-
Reports when the content is buffering.
Note
Analagous to theonBufferevent in version 3.x.Declaration
Swift
func jwplayerContentIsBuffering(_ player: JWPlayer)Parameters
playerThe player emitting the event.
-
Reports when additional data has been added to the buffer.
Note
Analagous to theonBufferChangeevent in version 3.x.Declaration
Swift
func jwplayer(_ player: JWPlayer, updatedBuffer percent: Double, position time: JWTimeData)Parameters
playerThe player emitting the event.
percentPercentage of the media which is currently buffered.
timeThe current position in the media file.
-
Reports when the content is complete.
Note
Analagous to theonCompleteevent in version 3.x.Declaration
Swift
func jwplayerContentDidComplete(_ player: JWPlayer)Parameters
playerThe player emitting the event.
-
Reports when the content has finished loading.
Note
Analagous to theonFirstFrameevent in version 3.x.Declaration
Swift
func jwplayer(_ player: JWPlayer, didFinishLoadingWithTime loadTime: TimeInterval)Parameters
playerThe player emitting the event.
loadTimeThe 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 theonPlayevent in version 3.x.Declaration
Swift
func jwplayer(_ player: JWPlayer, isPlayingWithReason reason: JWPlayReason)Parameters
playerThe player emitting the event.
reasonThe reason play has begun.
-
Reports when the player is about to play content.
Note
Analagous to theonPlayAttemptevent in version 3.x.Declaration
Swift
func jwplayer(_ player: JWPlayer, isAttemptingToPlay playlistItem: JWPlayerItem, reason: JWPlayReason)Parameters
playerThe player emitting the event.
playlistItemA description of the playlist item attempting to be played.
reasonThe reason the player is attempting to play the given item.
-
Reports when the content has paused.
Note
Analagous to theonPauseevent in version 3.x.Declaration
Swift
func jwplayer(_ player: JWPlayer, didPauseWithReason reason: JWPauseReason)Parameters
playerThe player emitting the event.
reasonThe reason the player became paused.
-
Reports when the content has become idle and is awaiting a new state or command.
Note
Analagous to theonIdleevent in version 3.x.Declaration
Swift
func jwplayer(_ player: JWPlayer, didBecomeIdleWithReason reason: JWIdleReason)Parameters
playerThe player emitting the event.
reasonThe 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 theonViewableevent in version 3.x.Declaration
Swift
func jwplayer(_ player: JWPlayer, isVisible: Bool)Parameters
playerThe player emitting the event.
isVisibleTrue, if the player is visible. False if it is not.
-
Reports when a new playlist has been loaded into the player.
Note
Analagous to theonPlaylistevent in version 3.x.Declaration
Swift
func jwplayer(_ player: JWPlayer, didLoadPlaylist playlist: [JWPlayerItem])Parameters
playerThe player emitting the event.
playlistAn array of playlist items in the playlist, in playlist order.
-
Reports when a new playlist has been loaded into the player.
Note
Analagous to theonPlaylistItemevent in version 3.x.Declaration
Swift
func jwplayer(_ player: JWPlayer, didLoadPlaylistItem item: JWPlayerItem, at index: UInt)Parameters
playerThe player emitting the event.
itemThe playlist item that has been loaded into the player.
indexThe index the playlist item in the playlist.
-
Reports when the entirety of the current playlist has finished playing.
Note
Analagous to theonPlaylistCompleteevent in version 3.x.Declaration
Swift
func jwplayerPlaylistHasCompleted(_ player: JWPlayer)Parameters
playerThe player emitting the event.
-
Reports when type of media has been loaded.
Declaration
Swift
func jwplayer(_ player: JWPlayer, usesMediaType type: JWMediaType)Parameters
playerThe player emitting the event.
typeThe type of media content being played.
-
Reports when content playback resumes after seeking.
Note
Analagous to theonSeekedevent in version 3.x.Declaration
Swift
func jwplayer(_ player: JWPlayer, seekedFrom oldPosition: TimeInterval, to newPosition: TimeInterval)Parameters
playerThe player emitting the event.
oldPositionThe position, in seconds, when seeking began.
newPositionThe position, in seconds, requested to be seeked to.
-
Reports when content playback resumes after seeking.
Note
Analagous to theonSeekedevent in version 3.x.Declaration
Swift
func jwplayerHasSeeked(_ player: JWPlayer)Parameters
playerThe 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
JWPlaybackStateDelegateNote
Analagous to theonPlaybackRateChangedevent in version 3.x.Declaration
Swift
func jwplayer(_ player: JWPlayer, playbackRateChangedTo rate: Double, at time: TimeInterval)Parameters
playerThe player emitting the event.
rateThe new playback rate.
timeThe position in the content, expressed in seconds, at which the playback rate changed.
-
Reports when the media has entered a time range designated as skippable.
Declaration
Swift
@available(tvOS 14, *) @available(iOS, unavailable) @objc optional func jwplayer(_ player: JWPlayer, enteredSkippableRange range: JWSkippableTimeRange)Parameters
playerThe player emitting the event.
rangeThe description of the skippable time range.
JWPlayerStateDelegate Protocol Reference