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:
Value | Description |
---|---|
code number | Identifier for the error See JW Player Errors Reference for a list of possible errors. |
error object | Object containing the error, most likely a playAttemptFailed warning |
reason string | Reason why the player could not autostart Possible value: • autoplayDisabled |
type string | Type 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:
Value | Description | Possible Outputs | Type |
---|---|---|---|
oldstate | The state the player moved from. | buffering | String |
viewable | If the player is viewable or not. | 0 | 1 | Number |
playReason | The 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:
Value | Description | Possible Values | Type |
---|---|---|---|
oldstate | The state the player moved from. | buffering | playing | String |
viewable | If the player is viewable or not. | 0 | 1 | Number |
pauseReason | The 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:
Value | Description | Type |
---|---|---|
error | The error that resulted from the play promise. | Object |
item | Returns everything in the playlist item. | Object |
playReason | The 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:
Value | Description | Possible Values | Type |
---|---|---|---|
oldstate | The state the player moved from. | buffering | playing | String |
newstate | The state the player moved to. | idle | playing | paused | String |
reason | The reason why a buffer event occurred. | loading | complete | stalled | error | String |
.on('idle')
Fired when the player enters the idle state.
Returns an object with the following:
Value | Description | Possible Outputs | Type |
---|---|---|---|
oldstate | The state the player moved from. | buffering | playing | paused | String |
.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.
Value | Description | Type |
---|---|---|
- | 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:
Value | Description | Type |
---|---|---|
loadTime | The amount of time (In milliseconds) it takes for the player to transition from a play attempt to a firstFrame event. | Number |
viewable | If the player is viewable or not. | Number |
.on('error')
Signals a critical error in the playback process.
Returns an object with the following:
Value | Description | Type |
---|---|---|
code | Identifier for the error See JW Player Errors Reference for a list of possible errors. | Number |
message | Text for the detected error See JW Player Errors Reference for a list of possible errors. | String |
sourceError | Lower level error or event, caught by the player, which resulted in this error | Object or null |
type | Category 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:
Value | Description | Type |
---|---|---|
code | Identifier for the warning See JW Player Errors Reference for a list of possible warnings. | Number |
message | Text for the detected warning See JW Player Errors Reference for a list of possible warnings. | String |
sourceError | Lower level error or event, caught by the player, which resulted in this warning | Object or null |
type | Category of warning This will always return warning . | String |
.on('playbackRateChanged')
Fired when the playback rate has been changed.
Returns an object with the following:
Value | Description | Type |
---|---|---|
playbackRate | The new playback rate | Number |
position | The position of the video when the playback rate was changed | Number |