From 855d7145d15d5267e4beceee78a1be66642d008a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Thu, 29 Aug 2024 12:07:00 +0200 Subject: [PATCH] fix: Don't throw an error when trying to disable a trick mode stream (#7235) --- lib/player.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/player.js b/lib/player.js index 629c7440e8..4838714c26 100644 --- a/lib/player.js +++ b/lib/player.js @@ -7260,19 +7260,32 @@ shaka.Player = class extends shaka.util.FakeEventTarget { if (hasAltStream) { let didDisableStream = false; + let isTrickModeVideo = false; + for (const variant of this.manifest_.variants) { const candidate = variant[stream.type]; - if (candidate && candidate.id === stream.id) { + if (!candidate) { + continue; + } + + if (candidate.id === stream.id) { variant.disabledUntilTime = (Date.now() / 1000) + disableTime; didDisableStream = true; shaka.log.v2( 'Disabled stream ' + stream.type + ':' + stream.id + ' for ' + disableTime + ' seconds...'); + } else if (candidate.trickModeVideo && + candidate.trickModeVideo.id == stream.id) { + isTrickModeVideo = true; } } + if (!didDisableStream && isTrickModeVideo) { + return false; + } + goog.asserts.assert(didDisableStream, 'Must have disabled stream'); this.checkVariantsTimer_.tickEvery(1);