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.
NOTE
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')
Fired when the active quality level is changed for HLS. This is different than levelsChanged since this will trigger when adaptive streaming automatically shifts quality.
Returns an object with the following:
Value | Description | Type |
---|---|---|
mode | The current type of quality selection. auto = automatic quality switching | manual = static quality | String |
label | Information about the new quality that was switched to. This returns the same information as getVisualQuality() | String |
reason | Why the quality was changed. See table below for possible reasons | String |
Possible Reasons
reason | Description |
---|---|
initial choice | The user had this quality set as a default and did not change it |
auto | An automatic quality change occurred |
api | The user chose a static quality after playback began, or an API was used to set it |