These API calls are used to listen to or update the video quality if multiple quality levels of a video are provided. Quality levels are sorted and given index numbers.
An index of 0 will always be "Auto".
.on('levels')
Fired when the list of available quality levels is updated. Happens e.g. shortly after a playlist item starts playing.
Returns an object with the following:
| Value | Description | Type |
|---|---|---|
| width | The new width of the player | Number |
| levels | The full array of qualities, including the new additions. Includes the same information as getQualityLevels() | Array |
.on('levelsChanged')
Fired when the active quality level is changed. Happens in response to e.g. a user clicking an option in the quality menu or a script calling setCurrentQuality.
Returns an object with the following:
| Value | Description | Type |
|---|---|---|
| currentQuality | index of the new quality level in the getQualityLevels() array | Number |
.on('visualQuality')
Fires when the active quality level is changed for HLS
This is different than levelsChanged since this will trigger when adaptive streaming automatically shifts quality.
{
"reason": "initial choice",
"mode": "auto",
"level": {
"bitrate": 700000,
"index": 1,
"label": "auto",
"width": 1280,
"height": 536
},
"type": "visualQuality"
}
| Property | Description |
|---|---|
| level object | Information for wach quality of a media item
See: level
|
| mode string | Current type of quality selection
Possible Values:
|
| reason string | Explanation for the quality change
Possible Values:
|
| type string | Category of the event
This is always visualQuality for this event.
|
level
| Property | Description |
|---|---|
| bitrate string | Bitrate of the media file |
| height number | Height of the media file |
| index number | Index of the quality level |
| label string | Label of the quality level |
| width number | Width of the media file |
