Captions Events

Captions

These API calls are used to listen to or update the active captions track if one or more closed captions tracks are provided with a video. The JavaScript API can be used to log captions usage or build your own CC menu outside JW Player. It is also possible to set caption styles dynamically using setCaptions() without having to reload the player.

πŸ“˜

`

An index of 0 implies that captions are off.


.on('captionsList')

Fired when the list of available captions tracks changes. This event is the ideal time to set default captions with the API.

πŸ“˜

captionsList will always return an array of at least 1 item due to off, but will trigger again once captions are fully loaded. We suggest only changing captions when the tracks array length exceeds 1.

Returns an array with the following:

ValueDescription
tracksΒ arrayAn array with all included captions tracks (Including "off"). Includes the same information as getCaptionsList()

.on('captionsChanged')

Triggered whenever the active captions track is changed manually or via API.

Returns an object with the following:

ValueDescription
track numberIndex of the new active captions track