These API calls are used to retrieve and change the current playback state of the player.
.on('autostartNotAllowed')
Fired when the player is configured to autostart but the browser's settings are preventing it
{
"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"
}
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('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:
|
oldstate string | State from which the player moved
Possible Values:
|
reason string | Reason why the buffer event occurred
Possible Values:
|
type string | Category of the event
This value is always buffer .
|
.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 This value is always complete .
|
.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:
|
oldstate string | State from which the player moved
Possible Values:
|
playReason string | Reason for the play
Possible Values:
|
reason string | Reason why the play event occurred
Possible Values:
|
type string | Category of the event
This is always play for this event.
|
viewable number | Whether the player is viewable
Possible Values:
|
.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:
|
oldstate string | State from which the player moved Possible values:
|
pauseReason string | Reason for the pause Possible values:
|
reason string | Reason why the pause event occurred Possible values:
|
type string | Category of the event Possible value:
|
viewable number | Whether the player is viewable Possible values:
|
.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('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:
|
oldstate string | State from which the player moved Possible values:
|
reason string | Reason why an idle event occurred Possible values:
|
type string | Category of the event Possible value:
|
.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 |