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('buffer')

Fired when one of the following events occurs:

  • Player starts playback
  • Player enters a buffering state
{
  "type": "buffer",
  "newstate": "buffering",
  "oldstate": "idle",
  "reason": "loading"
}
Value Description
newstate string State to which the player moved

Possible Values:
  • buffering
  • idle
  • playing
  • paused
  • stalled
oldstate string State from which the player moved

Possible Values:
  • buffering
  • idle
  • playing
  • paused
  • stalled
reason string Reason why the buffer event occurred

Possible Values:
  • paused
  • loading
  • complete
  • stalled
  • error
type string Category of the event

This is always buffer for this event.

.on('play')

Fired when non-advertising media within the player begins playback

To listen for an ad break play event, use .on('adPlay').

{
  "type": "play",
  "newstate": "playing",
  "oldstate": "buffering",
  "reason": "playing",
  "playReason": "interaction",
  "viewable": 1
}
Value Description
newstate string State to which the player moved

Possible Values:
  • buffering
  • idle
  • loading
  • paused
  • playing
  • stalled
oldstate string State from which the player moved

Possible Values:
  • buffering
  • idle
  • loading
  • paused
  • playing
  • stalled
playReason string Reason for the play

Possible Values:
  • autostart
  • external (API usage)
  • interaction: Click, touch, keyboard
  • playlist: Auto-advancing
  • related-audio: Auto-advancing JW Recommendations playlist
  • related-interaction: Interaction to go to a JW Recommendations playlist item
reason string Reason why the play event occurred

Possible Values:
  • autostart
  • clickthrough
  • external
  • interaction
type string Category of the event

This is always play for this event.
viewable number Whether the player is viewable

Possible Values:
  • 1
  • 0

.on('pause')

Fired when non-advertising media within the player is paused

To listen for an ad break pause event, use .on('adPause')

Value Description
newstate string State to which the player moved

Possible values:
  • buffering
  • idle
  • loading
  • paused
  • playing
  • stalled
oldstate string State from which the player moved

Possible values:
  • buffering
  • idle
  • loading
  • paused
  • playing
  • stalled
pauseReason string Reason for the pause

Possible values:
  • external
  • interaction
  • viewable
reason string Reason why the pause event occurred

Possible values:
  • autostart
  • clickthrough
  • external
  • interaction
  • paused
type string Category of the event

Possible value:
  • pause
viewable number Whether the player is viewable

Possible values:
  • 1
  • 0

.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('idle')

Fired when the player enters the idle state

{  
  "type": "idle",  
  "newstate": "idle",  
  "oldstate": "playing",  
  "reason": "complete"  
}  
Value Description
newstate string State to which the player moved

Possible values:
  • idle
  • playing
  • paused
oldstate string State from which the player moved

Possible values:
  • buffering
  • playing
  • paused
reason string Reason why an idle event occurred

Possible values:
  • complete
  • idle
  • error
  • pause
type string Category of the event

Possible value:
  • idle

.on('complete')

Fired when the end of a video is reached, but not when one of the following occurs:

  • The viewer advances playlist items prior to the end of a video
  • next() is called
{
  "type": "complete"
}
Value Description
type string Category of the event

Possible value:
  • complete

.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