diff --git a/AUTHORS b/AUTHORS index 207912e783..9b701a38d1 100644 --- a/AUTHORS +++ b/AUTHORS @@ -88,6 +88,7 @@ ViacomCBS <*@viacomcbs.com> Vincent Valot V-Nova Limited <*@v-nova.com> Wayne Morgan +Wen Ren Raymond Cheng Blue Billywig <*@bluebillywig.com> João Nabais diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 1b272e8878..aa611ec22e 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -127,6 +127,7 @@ Vignesh Venkatasubramanian Vincent Valot Vinod Balakrishnan Wayne Morgan +Wen Ren Yohann Connell Raymond Cheng Janroel Koppen diff --git a/lib/player.js b/lib/player.js index a6626abb9a..4d6e20e5c3 100644 --- a/lib/player.js +++ b/lib/player.js @@ -4242,9 +4242,15 @@ shaka.Player = class extends shaka.util.FakeEventTarget { * are expected to have the same variant.audio. * * @param {string} label + * @param {boolean=} clearBuffer Optional clear buffer or not when + * switch to new variant + * Defaults to true if not provided + * @param {number=} safeMargin Optional amount of buffer (in seconds) to + * retain when clearing the buffer. + * Defaults to 0 if not provided. Ignored if clearBuffer is false. * @export */ - selectVariantsByLabel(label) { + selectVariantsByLabel(label, clearBuffer = true, safeMargin = 0) { if (this.manifest_ && this.playhead_) { let firstVariantWithLabel = null; for (const variant of this.manifest_.variants) { @@ -4268,7 +4274,7 @@ shaka.Player = class extends shaka.util.FakeEventTarget { new shaka.media.PreferenceBasedCriteria( firstVariantWithLabel.language, '', 0, label); - this.chooseVariantAndSwitch_(); + this.chooseVariantAndSwitch_(clearBuffer, safeMargin); } } @@ -5713,9 +5719,15 @@ shaka.Player = class extends shaka.util.FakeEventTarget { * Called after a config change, a key status event, or an explicit language * change. * + * @param {boolean=} clearBuffer Optional clear buffer or not when + * switch to new variant + * Defaults to true if not provided + * @param {number=} safeMargin Optional amount of buffer (in seconds) to + * retain when clearing the buffer. + * Defaults to 0 if not provided. Ignored if clearBuffer is false. * @private */ - chooseVariantAndSwitch_() { + chooseVariantAndSwitch_(clearBuffer = true, safeMargin = 0) { goog.asserts.assert(this.config_, 'Must not be destroyed'); // Because we're running this after a config change (manual language @@ -5724,7 +5736,7 @@ shaka.Player = class extends shaka.util.FakeEventTarget { const chosenVariant = this.chooseVariant_(); if (chosenVariant) { this.switchVariant_(chosenVariant, /* fromAdaptation= */ true, - /* clearBuffers= */ true, /* safeMargin= */ 0); + clearBuffer, safeMargin); } }