From 73db8b317264bc52205a801c59dbb29e6a4cff89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Fri, 20 Dec 2024 12:39:16 +0100 Subject: [PATCH] fix(UI): Video starts playing automatically when selecting a playback rate (#7786) Fixes https://github.com/shaka-project/shaka-player/issues/7756 --- lib/player.js | 6 ------ ui/fast_forward_button.js | 7 +++++++ ui/rewind_button.js | 7 +++++++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/player.js b/lib/player.js index 5124fe33e3..475369350d 100644 --- a/lib/player.js +++ b/lib/player.js @@ -4606,12 +4606,6 @@ shaka.Player = class extends shaka.util.FakeEventTarget { } this.trickPlayEventManager_.removeAll(); - if (this.video_.paused) { - // Our fast forward is implemented with playbackRate and needs the video - // to be playing (to not be paused) to take immediate effect. - // If the video is paused, "unpause" it. - this.video_.play(); - } this.playRateController_.set(rate); if (this.loadMode_ == shaka.Player.LoadMode.MEDIA_SOURCE) { diff --git a/ui/fast_forward_button.js b/ui/fast_forward_button.js index 42ce5923ae..25f9fa847e 100644 --- a/ui/fast_forward_button.js +++ b/ui/fast_forward_button.js @@ -81,6 +81,13 @@ shaka.ui.FastForwardButton = class extends shaka.ui.Element { // selected. If no more rates are available, the first one is set. const newRate = (newRateIndex != this.fastForwardRates_.length) ? this.fastForwardRates_[newRateIndex] : this.fastForwardRates_[0]; + + if (this.video.paused) { + // Our fast forward is implemented with playbackRate and needs the video + // to be playing (to not be paused) to take immediate effect. + // If the video is paused, "unpause" it. + this.video.play(); + } this.player.trickPlay(newRate); this.button_.setAttribute('shaka-status', newRate + 'x'); diff --git a/ui/rewind_button.js b/ui/rewind_button.js index cff00f857f..6b8b95c632 100644 --- a/ui/rewind_button.js +++ b/ui/rewind_button.js @@ -82,6 +82,13 @@ shaka.ui.RewindButton = class extends shaka.ui.Element { // selected. If no more rates are available, the first one is set. const newRate = (newRateIndex != this.rewindRates_.length) ? this.rewindRates_[newRateIndex] : this.rewindRates_[0]; + + if (this.video.paused) { + // Our fast forward is implemented with playbackRate and needs the video + // to be playing (to not be paused) to take immediate effect. + // If the video is paused, "unpause" it. + this.video.play(); + } this.player.trickPlay(newRate); this.button_.setAttribute('shaka-status', newRate + 'x');