From ba97b4a249aea8c4522c95552ad770ea7be4ecfc Mon Sep 17 00:00:00 2001 From: AgustinSRG Date: Tue, 1 Oct 2024 17:41:34 +0200 Subject: [PATCH] Frontend: Custom playback speed (with slider) --- .../components/player/AudioPlayerConfig.vue | 74 ++++++++++++++++++- .../components/player/VideoPlayerConfig.vue | 72 +++++++++++++++++- 2 files changed, 144 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/player/AudioPlayerConfig.vue b/frontend/src/components/player/AudioPlayerConfig.vue index 89473f2..51cac75 100644 --- a/frontend/src/components/player/AudioPlayerConfig.vue +++ b/frontend/src/components/player/AudioPlayerConfig.vue @@ -154,13 +154,16 @@ + - + + + + + +
{{ $t("Playback speed") }} + {{ $t("Custom") }} +
@@ -169,7 +172,53 @@
+ + {{ $t("Custom") }}: {{ renderSpeed(speed) }} +
+ + + + + + + + + + + + + +
+ + {{ $t("Playback speed") }} ({{ $t("Custom") }}) +
+ +
+ + % +
+ - + + + + + +
@@ -403,6 +452,8 @@ export default defineComponent({ speeds: [0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2], animStyles: ["gradient", "rainbow", "", "none"], + speedNum: Math.floor(this.speed * 100), + subtitles: "", subtitlesSizes: ["s", "m", "l", "xl", "xxl"], @@ -493,6 +544,16 @@ export default defineComponent({ this.focus(); }, + goToCustomSpeed: function (e?: Event) { + if (e) { + e.preventDefault(); + e.stopPropagation(); + } + + this.page = "speed-custom"; + this.focus(); + }, + renderSpeed: function (speed: number) { if (speed > 1) { return Math.floor(speed * 100) + "%"; @@ -619,6 +680,14 @@ export default defineComponent({ this.saveCustomSubtitleSize(); }, + updateSpeedNum: function () { + if (typeof this.speedNum !== "number" || isNaN(this.speedNum) || this.speedNum < 0.1) { + return; + } + + this.speedState = this.speedNum / 100; + }, + clickOnEnter: function (event: KeyboardEvent) { if (event.key === "Enter") { event.preventDefault(); @@ -666,6 +735,9 @@ export default defineComponent({ } this.subSizeCustomNum = this.subSizeCustom; }, + speed: function () { + this.speedNum = Math.floor(this.speed * 100); + }, }, }); diff --git a/frontend/src/components/player/VideoPlayerConfig.vue b/frontend/src/components/player/VideoPlayerConfig.vue index e4edfd6..ecaa2a0 100644 --- a/frontend/src/components/player/VideoPlayerConfig.vue +++ b/frontend/src/components/player/VideoPlayerConfig.vue @@ -177,7 +177,9 @@ {{ $t("Playback speed") }} + {{ $t("Custom") }} +
@@ -186,6 +188,51 @@
+ + {{ $t("Custom") }}: {{ renderSpeed(speed) }} +
+ + + + + + + + + + + + + +
+ + {{ $t("Playback speed") }} ({{ $t("Custom") }}) +
+ +
+ + % +
@@ -511,6 +558,8 @@ export default defineComponent({ scales: [1, 1.25, 1.5, 1.75, 2, 4, 8], resolutions: [], + speedNum: Math.floor(this.speed * 100), + subtitles: "", subtitlesSizes: ["s", "m", "l", "xl", "xxl"], subtitlesBackgrounds: ["100", "75", "50", "25", "0"], @@ -642,6 +691,16 @@ export default defineComponent({ this.focus(); }, + goToCustomSpeed: function (e?: Event) { + if (e) { + e.preventDefault(); + e.stopPropagation(); + } + + this.page = "speed-custom"; + this.focus(); + }, + renderSpeed: function (speed: number) { if (speed > 1) { return Math.floor(speed * 100) + "%"; @@ -828,6 +887,14 @@ export default defineComponent({ this.saveCustomSubtitleSize(); }, + updateSpeedNum: function () { + if (typeof this.speedNum !== "number" || isNaN(this.speedNum) || this.speedNum < 0.1) { + return; + } + + this.speedState = this.speedNum / 100; + }, + clickOnEnter: function (event: KeyboardEvent) { if (event.key === "Enter") { event.preventDefault(); @@ -876,6 +943,9 @@ export default defineComponent({ } this.subSizeCustomNum = this.subSizeCustom; }, + speed: function () { + this.speedNum = Math.floor(this.speed * 100); + }, rTick: function () { this.updateResolutions(); },