From 40699b9ae323e923bdfa7ac0070e99fcdb742714 Mon Sep 17 00:00:00 2001 From: PrestonN Date: Sun, 10 Apr 2022 18:00:47 -0400 Subject: [PATCH] Customize max playback rate and playback rate interval --- .../ft-video-player/ft-video-player.js | 45 +++++++++++-------- .../player-settings/player-settings.js | 18 +++++++- .../player-settings/player-settings.vue | 16 +++++++ src/renderer/store/modules/settings.js | 2 + static/locales/en-US.yaml | 2 + 5 files changed, 64 insertions(+), 19 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 3d94c5d6..f50c888e 100644 --- a/src/renderer/components/ft-video-player/ft-video-player.js +++ b/src/renderer/components/ft-video-player/ft-video-player.js @@ -126,21 +126,7 @@ export default Vue.extend({ 'qualitySelector', 'fullscreenToggle' ] - }, - playbackRates: [ - 0.25, - 0.5, - 0.75, - 1, - 1.25, - 1.5, - 1.75, - 2, - 2.25, - 2.5, - 2.75, - 3 - ] + } } } }, @@ -200,6 +186,27 @@ export default Vue.extend({ displayVideoPlayButton: function() { return this.$store.getters.getDisplayVideoPlayButton + }, + + maxVideoPlaybackRate: function () { + return parseInt(this.$store.getters.getMaxVideoPlaybackRate) + }, + + videoPlaybackRateInterval: function () { + return parseFloat(this.$store.getters.getVideoPlaybackRateInterval) + }, + + playbackRates: function () { + const playbackRates = [] + let i = this.videoPlaybackRateInterval + + while (i <= this.maxVideoPlaybackRate) { + playbackRates.push(i) + i = i + this.videoPlaybackRateInterval + i = parseFloat(i.toFixed(2)) + } + + return playbackRates } }, watch: { @@ -216,6 +223,8 @@ export default Vue.extend({ this.volume = volume } + this.dataSetup.playbackRates = this.playbackRates + this.createFullWindowButton() this.createLoopButton() this.createToggleTheatreModeButton() @@ -983,7 +992,7 @@ export default Vue.extend({ changePlayBackRate: function (rate) { const newPlaybackRate = (this.player.playbackRate() + rate).toFixed(2) - if (newPlaybackRate >= 0.25 && newPlaybackRate <= 8) { + if (newPlaybackRate >= this.videoPlaybackRateInterval && newPlaybackRate <= this.maxVideoPlaybackRate) { this.player.playbackRate(newPlaybackRate) } }, @@ -1515,13 +1524,13 @@ export default Vue.extend({ // O Key // Decrease playback rate by 0.25x event.preventDefault() - this.changePlayBackRate(-0.25) + this.changePlayBackRate(-this.videoPlaybackRateInterval) break case 80: // P Key // Increase playback rate by 0.25x event.preventDefault() - this.changePlayBackRate(0.25) + this.changePlayBackRate(this.videoPlaybackRateInterval) break case 70: // F Key diff --git a/src/renderer/components/player-settings/player-settings.js b/src/renderer/components/player-settings/player-settings.js index 55e24c81..1f0666f8 100644 --- a/src/renderer/components/player-settings/player-settings.js +++ b/src/renderer/components/player-settings/player-settings.js @@ -30,6 +30,12 @@ export default Vue.extend({ 480, 720, 1080 + ], + playbackRateIntervalValues: [ + 0.1, + 0.25, + 0.5, + 1 ] } }, @@ -106,6 +112,14 @@ export default Vue.extend({ return this.$store.getters.getDisplayVideoPlayButton }, + maxVideoPlaybackRate: function () { + return parseInt(this.$store.getters.getMaxVideoPlaybackRate) + }, + + videoPlaybackRateInterval: function () { + return this.$store.getters.getVideoPlaybackRateInterval + }, + formatNames: function () { return [ this.$t('Settings.Player Settings.Default Video Format.Dash Formats'), @@ -143,7 +157,9 @@ export default Vue.extend({ 'updateDefaultQuality', 'updateVideoVolumeMouseScroll', 'updateVideoPlaybackRateMouseScroll', - 'updateDisplayVideoPlayButton' + 'updateDisplayVideoPlayButton', + 'updateMaxVideoPlaybackRate', + 'updateVideoPlaybackRateInterval' ]) } }) diff --git a/src/renderer/components/player-settings/player-settings.vue b/src/renderer/components/player-settings/player-settings.vue index f6f80842..ab1577cc 100644 --- a/src/renderer/components/player-settings/player-settings.vue +++ b/src/renderer/components/player-settings/player-settings.vue @@ -115,6 +115,22 @@ value-extension="×" @change="updateDefaultPlayback" /> + +