Quality Events

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:

ValueDescriptionType
widthThe new width of the playerNumber
levelsThe 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:

ValueDescriptionType
currentQualityindex of the new quality level in the getQualityLevels() arrayNumber

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

ValueDescriptionType
modeThe current type of quality selection. auto = automatic quality switching | manual = static qualityString
labelInformation about the new quality that was switched to. This returns the same information as getVisualQuality()String
reasonWhy the quality was changed. See table below for possible reasonsString

Possible Reasons

reasonDescription
initial choiceThe user had this quality set as a default and did not change it
autoAn automatic quality change occurred
apiThe user chose a static quality after playback began, or an API was used to set it