From d45a41ac7e4214a4a8f98a87bc8c513a5ae2f510 Mon Sep 17 00:00:00 2001 From: Dev Date: Mon, 20 Feb 2023 08:49:24 +0530 Subject: [PATCH 1/6] Made changes as suggested. --- .../components/ft-video-player/ft-video-player.js | 15 +++++++++++++-- src/renderer/store/modules/settings.js | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/renderer/components/ft-video-player/ft-video-player.js b/src/renderer/components/ft-video-player/ft-video-player.js index 332ceb13ed28..1b98d4a36bc0 100644 --- a/src/renderer/components/ft-video-player/ft-video-player.js +++ b/src/renderer/components/ft-video-player/ft-video-player.js @@ -89,6 +89,7 @@ export default defineComponent({ id: '', powerSaveBlocker: null, volume: 1, + muted: false, player: null, useDash: false, useHls: false, @@ -315,11 +316,18 @@ export default defineComponent({ }, mounted: function () { const volume = sessionStorage.getItem('volume') + const muted = sessionStorage.getItem('muted') if (volume !== null) { this.volume = volume } + if (muted !== null) { + // as sessionStorage stores string values which are truthy by default so we must check with 'true' + // otherwise 'false' will be returned as true as well + this.muted = (muted === 'true') + } + this.dataSetup.playbackRates = this.playbackRates this.createFullWindowButton() @@ -400,6 +408,7 @@ export default defineComponent({ }) this.player.volume(this.volume) + this.player.muted(this.muted) this.player.playbackRate(this.defaultPlayback) this.player.textTrackSettings.setValues(this.defaultCaptionSettings) // Remove big play button @@ -712,10 +721,12 @@ export default defineComponent({ }, updateVolume: function (_event) { - // 0 means muted // https://docs.videojs.com/html5#volume - const volume = this.player.muted() ? 0 : this.player.volume() + const volume = this.player.volume() + const muted = this.player.muted() + sessionStorage.setItem('volume', volume) + sessionStorage.setItem('muted', muted) }, mouseScrollVolume: function (event) { diff --git a/src/renderer/store/modules/settings.js b/src/renderer/store/modules/settings.js index 0476e182ef2e..1dc36f82216f 100644 --- a/src/renderer/store/modules/settings.js +++ b/src/renderer/store/modules/settings.js @@ -349,6 +349,7 @@ const stateWithSideEffects = { defaultValue: 1, sideEffectsHandler: (_, value) => { sessionStorage.setItem('volume', value) + value === 0 ? sessionStorage.setItem('muted', true) : sessionStorage.setItem('muted', false) } }, From 3876b5555188f5024538d6ae003f292e244e15fe Mon Sep 17 00:00:00 2001 From: Dev Date: Mon, 20 Feb 2023 11:49:05 +0530 Subject: [PATCH 2/6] Made player set volume to user default if it was muted by dragging volume slider to zero. Volume and muted are kept track of seperately and both are set on player with respect to how it was set for previous video --- .../ft-video-player/ft-video-player.js | 21 ++++++++++++++----- src/renderer/store/modules/settings.js | 3 ++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/renderer/components/ft-video-player/ft-video-player.js b/src/renderer/components/ft-video-player/ft-video-player.js index 1b98d4a36bc0..8c88d23c1542 100644 --- a/src/renderer/components/ft-video-player/ft-video-player.js +++ b/src/renderer/components/ft-video-player/ft-video-player.js @@ -328,6 +328,11 @@ export default defineComponent({ this.muted = (muted === 'true') } + if (muted === 'false' && volume === '0') { + this.muted = true + sessionStorage.setItem('volume', 0.25) + } + this.dataSetup.playbackRates = this.playbackRates this.createFullWindowButton() @@ -722,11 +727,17 @@ export default defineComponent({ updateVolume: function (_event) { // https://docs.videojs.com/html5#volume - const volume = this.player.volume() - const muted = this.player.muted() - - sessionStorage.setItem('volume', volume) - sessionStorage.setItem('muted', muted) + if (sessionStorage.getItem('muted') === 'false' && this.player.volume() === 0) { + const volume = parseFloat(sessionStorage.getItem('defaultVolume')) + const muted = true + sessionStorage.setItem('volume', volume) + sessionStorage.setItem('muted', muted) + } else { + const volume = this.player.volume() + const muted = this.player.muted() + sessionStorage.setItem('volume', volume) + sessionStorage.setItem('muted', muted) + } }, mouseScrollVolume: function (event) { diff --git a/src/renderer/store/modules/settings.js b/src/renderer/store/modules/settings.js index 1dc36f82216f..8c02127232e6 100644 --- a/src/renderer/store/modules/settings.js +++ b/src/renderer/store/modules/settings.js @@ -349,7 +349,8 @@ const stateWithSideEffects = { defaultValue: 1, sideEffectsHandler: (_, value) => { sessionStorage.setItem('volume', value) - value === 0 ? sessionStorage.setItem('muted', true) : sessionStorage.setItem('muted', false) + value === 0 ? sessionStorage.setItem('muted', 'true') : sessionStorage.setItem('muted', 'false') + sessionStorage.setItem('defaultVolume', value) } }, From 9c3ea46800e0aa1343c22be33626ad85d752622d Mon Sep 17 00:00:00 2001 From: Dev Date: Mon, 20 Feb 2023 14:20:57 +0530 Subject: [PATCH 3/6] added comments --- src/renderer/components/ft-video-player/ft-video-player.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/renderer/components/ft-video-player/ft-video-player.js b/src/renderer/components/ft-video-player/ft-video-player.js index 8c88d23c1542..af2bcd2582e8 100644 --- a/src/renderer/components/ft-video-player/ft-video-player.js +++ b/src/renderer/components/ft-video-player/ft-video-player.js @@ -728,11 +728,14 @@ export default defineComponent({ updateVolume: function (_event) { // https://docs.videojs.com/html5#volume if (sessionStorage.getItem('muted') === 'false' && this.player.volume() === 0) { + // If video was muted by dragging volume slider, we reset the volume to default volume. + // dragging volume to 0 doesn't change muted in sessionStorage to true hence checking it with 'false' const volume = parseFloat(sessionStorage.getItem('defaultVolume')) const muted = true sessionStorage.setItem('volume', volume) sessionStorage.setItem('muted', muted) } else { + // If video was muted by pressing 'm'/'M' or clicking on mute button, then we reset the volume to previous volume. const volume = this.player.volume() const muted = this.player.muted() sessionStorage.setItem('volume', volume) From f4e684e8cb7a1a406205a1a826c0a3de2a312149 Mon Sep 17 00:00:00 2001 From: Dev Date: Tue, 21 Feb 2023 01:15:26 +0530 Subject: [PATCH 4/6] fixed --- src/renderer/components/ft-video-player/ft-video-player.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/renderer/components/ft-video-player/ft-video-player.js b/src/renderer/components/ft-video-player/ft-video-player.js index af2bcd2582e8..8484a427ced0 100644 --- a/src/renderer/components/ft-video-player/ft-video-player.js +++ b/src/renderer/components/ft-video-player/ft-video-player.js @@ -328,11 +328,6 @@ export default defineComponent({ this.muted = (muted === 'true') } - if (muted === 'false' && volume === '0') { - this.muted = true - sessionStorage.setItem('volume', 0.25) - } - this.dataSetup.playbackRates = this.playbackRates this.createFullWindowButton() @@ -411,7 +406,6 @@ export default defineComponent({ tapTimeout: 300 } }) - this.player.volume(this.volume) this.player.muted(this.muted) this.player.playbackRate(this.defaultPlayback) From b8d641b80bbdc7fa24d4ed59c6ddc1ac8a6a25ce Mon Sep 17 00:00:00 2001 From: Dev Date: Tue, 21 Feb 2023 01:18:00 +0530 Subject: [PATCH 5/6] fixed --- src/renderer/components/ft-video-player/ft-video-player.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/renderer/components/ft-video-player/ft-video-player.js b/src/renderer/components/ft-video-player/ft-video-player.js index 8484a427ced0..3f179ceb09fd 100644 --- a/src/renderer/components/ft-video-player/ft-video-player.js +++ b/src/renderer/components/ft-video-player/ft-video-player.js @@ -406,6 +406,7 @@ export default defineComponent({ tapTimeout: 300 } }) + this.player.volume(this.volume) this.player.muted(this.muted) this.player.playbackRate(this.defaultPlayback) From 917b5b9eb22addde32fff98d351e0f236ef226c7 Mon Sep 17 00:00:00 2001 From: Dev Date: Tue, 21 Feb 2023 13:21:39 +0530 Subject: [PATCH 6/6] Changed comments to be more accurate. --- src/renderer/components/ft-video-player/ft-video-player.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/renderer/components/ft-video-player/ft-video-player.js b/src/renderer/components/ft-video-player/ft-video-player.js index 3f179ceb09fd..c9bdd09aadb9 100644 --- a/src/renderer/components/ft-video-player/ft-video-player.js +++ b/src/renderer/components/ft-video-player/ft-video-player.js @@ -723,14 +723,14 @@ export default defineComponent({ updateVolume: function (_event) { // https://docs.videojs.com/html5#volume if (sessionStorage.getItem('muted') === 'false' && this.player.volume() === 0) { - // If video was muted by dragging volume slider, we reset the volume to default volume. - // dragging volume to 0 doesn't change muted in sessionStorage to true hence checking it with 'false' + // If video is muted by dragging volume slider, it doesn't change 'muted' in sessionStorage to true + // hence compare it with 'false' and set volume to defaultVolume. const volume = parseFloat(sessionStorage.getItem('defaultVolume')) const muted = true sessionStorage.setItem('volume', volume) sessionStorage.setItem('muted', muted) } else { - // If video was muted by pressing 'm'/'M' or clicking on mute button, then we reset the volume to previous volume. + // If volume isn't muted by dragging the slider, muted and volume values are carried over to next video. const volume = this.player.volume() const muted = this.player.muted() sessionStorage.setItem('volume', volume)