Captions Events

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 the JWX 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')

Fires 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.

{
    "tracks": [
        {
            "id": "off",
            "label": "Off"
        },
        {
            "id": "//playertest-cdn.longtailvideo.com/assets/os/captions/bunny-en.srt",
            "label": "English",
            "language": "en"
        }
    ],
    "track": 0,
    "type": "captionsList"
}
PropertyDescription
track numberIndex of the active captions track
tracks array

All included captions tracks



See: tracks[]

type string

Category of player event



This is always captionsList for this event.


tracks[]

PropertyDescription
id string | number

(Sideloaded Captions: .srt, .vtt) URL of the sideloaded captions file



(Embedded Captions: .vtt, CEA-608, CEA-708) Index of the caption



NOTE: The id value of the first tracks[] object is always off. The first track indicates that captions are off.

label string

(Sideloaded Captions: .srt, .vtt) Label configured in the player setup



(Embedded Captions: .vtt, CEA-608, CEA-708) Label specified within the embedded captions



NOTE: The label value of the first tracks[] object is always Off. The first track indicates that captions are off.

language stringTwo-letter language abbreviation for the captions track


.on('captionsChanged')

Triggers whenever the active captions track is changed manually or via API

{
    "tracks": [
        {
            "id": "off",
            "label": "Off"
        },
        {
            "id": "//playertest-cdn.longtailvideo.com/assets/os/captions/bunny-en.srt",
            "label": "English",
            "language": "en"
        }
    ],
    "track": 0,
    "type": "captionsChanged"
}
PropertyDescription
track numberIndex of the new active captions track
tracks array

All included captions tracks



See: tracks[]

type string

Category of player event



This is always captionsChanged for this event.


tracks[]

PropertyDescription
id string | number

(Sideloaded Captions: .srt, .vtt) URL of the sideloaded captions file



(Embedded Captions: .vtt, CEA-608, CEA-708) Index of the caption



NOTE: The id value of the first tracks[] object is always off. The first track indicates that captions are off.

label string

(Sideloaded Captions: .srt, .vtt) Label configured in the player setup



(Embedded Captions: .vtt, CEA-608, CEA-708) Label specified within the embedded captions



NOTE: The label value of the first tracks[] object is always Off. The first track indicates that captions are off.

language stringTwo-letter language abbreviation for the captions track
© 2007- Longtail Ad Solutions, Inc.