Skip to content

Commit

Permalink
Reenable variants from switch_
Browse files Browse the repository at this point in the history
  • Loading branch information
albertdaurell committed May 3, 2022
1 parent 9d08e98 commit fdcc2ae
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -5399,6 +5399,7 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
* @private
*/
switch_(variant, clearBuffer = false, safeMargin = 0) {
let currentVariant = variant;
shaka.log.debug('switch_');
goog.asserts.assert(this.config_.abr.enabled,
'AbrManager should not call switch while disabled!');
Expand All @@ -5410,12 +5411,30 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
return;
}

if (variant == this.streamingEngine_.getCurrentVariant()) {
// Check if there are disabled variants and reenable if possible
const disabledVariants = this.manifest_.variants
.some(({disabledTime}) => disabledTime);
if (disabledVariants) {
const tracksChanged = shaka.util.StreamUtils.applyRestrictions(
this.manifest_.variants, this.config_.restrictions,
this.maxHwRes_);
if (tracksChanged) {
const chosenVariant = this.chooseVariant_();
if (chosenVariant) {
shaka.log.debug('>>>>>>>>>> SWITCHED');
currentVariant = chosenVariant;
} else {
shaka.log.debug('>>>>>>>>>> OPSSS');
}
}
}

if (currentVariant == this.streamingEngine_.getCurrentVariant()) {
// This isn't a change.
return;
}

this.switchVariant_(variant, /* fromAdaptation= */ true,
this.switchVariant_(currentVariant, /* fromAdaptation= */ true,
clearBuffer, safeMargin);
}

Expand Down

0 comments on commit fdcc2ae

Please sign in to comment.