Skip to content

Commit 014e821

Browse files
committed
Add option hslQualityChangeStrategy,
set option to nextLevel instead of currentLevel. This means that the next fragment will load with the set quality instead of the current. This results in smoother playback when compared to currentLevel
1 parent 42dc804 commit 014e821

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/quality/quality.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ Object.assign(mejs.MepDefaults, {
2424
* @type {boolean}
2525
*/
2626
autoGenerate: false,
27+
/**
28+
* @type {String}
29+
*/
30+
hslQualityChangeStrategy: 'nextLevel',
2731
/**
2832
* @type {boolean}
2933
*/
@@ -415,13 +419,14 @@ Object.assign(MediaElementPlayer.prototype, {
415419
* @param {MediaElement} media
416420
*/
417421
switchHLSQuality (player, media) {
422+
const t = this;
418423
const radios = player.qualitiesContainer.querySelectorAll('input[type="radio"]');
419424
for (let index = 0; index < radios.length; index++) {
420425
if (radios[index].checked) {
421426
if (index === 0 ) {
422-
media.hlsPlayer.currentLevel = -1;
427+
media.hlsPlayer[t.options.hslQualityChangeStrategy] = -1;
423428
} else {
424-
media.hlsPlayer.currentLevel = index - 1;
429+
media.hlsPlayer[t.options.hslQualityChangeStrategy] = index - 1;
425430
}
426431
}
427432
}

0 commit comments

Comments
 (0)