Playback Events

These API calls are used to retrieve and change the current playback state of the player.


.on('autostartNotAllowed')

{
    "code": 303220,
    "error": "The play method is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.",
    "reason": "autoplayDisabled",
    "type": "autostartNotAllowed"
}

Fired when the player is configured to autostart but the browser's settings are preventing it.

Returns an object with the following:

ValueDescription
code numberIdentifier for the error

See JW Player Errors Reference for a list of possible errors.
error objectObject containing the error, most likely a playAttemptFailedwarning
reason stringReason why the player could not autostart

Possible value:
autoplayDisabled
type stringType of event that is fired

Possible value:
autostartNotAllowed

.on('play')

Fired when the player enters the playing state

The play event fires when non-advertising media within the player begins playback. To listen for an ad break play event, use .on('adPlay').

Returns an object with the following:

ValueDescriptionPossible OutputsType
oldstateThe state the player moved from.bufferingString
viewableIf the player is viewable or not.0 | 1Number
playReasonThe reason for the play.

Possible values:
   •autostart
   • external (API usage)
   • interaction (click, touch, keyboard)
   • playlist (due to autoadvancing)
   • related-auto (auto-advancing JW Recommendations playlist)
   •related-interaction (interaction to go to a JW Recommendations playlist item)
   • viewable (for autopause)
String

.on('pause')

Fired when the player enters the paused state


The pause event fires when non-advertising media within the player is paused. To listen for an ad break pause event, use .on('adPause').

Returns an object with the following:

ValueDescriptionPossible ValuesType
oldstateThe state the player moved from.buffering | playingString
viewableIf the player is viewable or not.0 | 1Number
pauseReasonThe reason for the pause, such as interaction, API, external, or a custom reason.String

.on('playAttemptFailed')

Fired when playback is aborted or blocked. A failed play attempt does not result in a play. Pausing the video or changing the media results in play attempts being aborted. In mobile browsers play attempts are blocked when not started by a user gesture.

Returns an object with the following:

ValueDescriptionType
errorThe error that resulted from the play promise.Object
itemReturns everything in the playlist item.Object
playReasonThe reason for the play, such as interaction, API, external, or a custom reason.String

.on('buffer')

Fired when the player starts playback and when the player enters a buffering state.

Returns an object with the following:

ValueDescriptionPossible ValuesType
oldstateThe state the player moved from.buffering | playingString
newstateThe state the player moved to.idle | playing | pausedString
reasonThe reason why a buffer event occurred.loading | complete | stalled | errorString

.on('idle')

Fired when the player enters the idle state.

Returns an object with the following:

ValueDescriptionPossible OutputsType
oldstateThe state the player moved from.buffering | playing | pausedString

.on('complete')

Fires each time the end of a video is reached.

This does not fire if the viewer advances playlist items prior to the end of a video, or if next() is called.

ValueDescriptionType
-No value returned-

.on('firstFrame')

Use this to determine the period of time between a user pressing play and the same user viewing their content. Triggered by a video's first frame event (or the instant an audio file begins playback). This event pinpoints when content playback begins.

Returns an object with the following:

ValueDescriptionType
loadTimeThe amount of time (In milliseconds) it takes for the player to transition from a play attempt to a firstFrame event.Number
viewableIf the player is viewable or not.Number

.on('error')

Signals a critical error in the playback process.

Returns an object with the following:

ValueDescriptionType
codeIdentifier for the error
See JW Player Errors Reference for a list of possible errors.
Number
messageText for the detected error
See JW Player Errors Reference for a list of possible errors.
String
sourceErrorLower level error or event, caught by the player, which resulted in this errorObject or null
typeCategory of error
This will always return error.
String

.on('warning')

Signals a failure that is not critical to the setup or playback process.

Returns an object with the following:

ValueDescriptionType
codeIdentifier for the warning
See JW Player Errors Reference for a list of possible warnings.
Number
messageText for the detected warning
See JW Player Errors Reference for a list of possible warnings.
String
sourceErrorLower level error or event, caught by the player, which resulted in this warningObject or null
typeCategory of warning
This will always return warning.
String

.on('playbackRateChanged')

Fired when the playback rate has been changed.

Returns an object with the following:

ValueDescriptionType
playbackRateThe new playback rateNumber
positionThe position of the video when the playback rate was changedNumber