From a59311f795236195c21763d1673d892e231f38d6 Mon Sep 17 00:00:00 2001 From: advplyr Date: Fri, 7 Apr 2023 18:05:23 -0500 Subject: [PATCH] Update:Adjust timestamps in player for playback speed #1647 --- client/components/app/StreamContainer.vue | 11 ++++----- client/components/modals/ChaptersModal.vue | 25 ++++++++++++--------- client/components/player/PlayerTrackBar.vue | 21 ++++++++++------- client/components/player/PlayerUi.vue | 14 +++++++----- 4 files changed, 42 insertions(+), 29 deletions(-) diff --git a/client/components/app/StreamContainer.vue b/client/components/app/StreamContainer.vue index 470106ba..fa41b528 100644 --- a/client/components/app/StreamContainer.vue +++ b/client/components/app/StreamContainer.vue @@ -81,7 +81,7 @@ export default { sleepTimerRemaining: 0, sleepTimer: null, displayTitle: null, - initialPlaybackRate: 1, + currentPlaybackRate: 1, syncFailedToast: null } }, @@ -152,7 +152,8 @@ export default { return this.streamLibraryItem ? this.streamLibraryItem.libraryId : null }, totalDurationPretty() { - return this.$secondsToTimestamp(this.totalDuration) + // Adjusted by playback rate + return this.$secondsToTimestamp(this.totalDuration / this.currentPlaybackRate) }, podcastAuthor() { if (!this.isPodcast) return null @@ -255,7 +256,7 @@ export default { this.playerHandler.setVolume(volume) }, setPlaybackRate(playbackRate) { - this.initialPlaybackRate = playbackRate + this.currentPlaybackRate = playbackRate this.playerHandler.setPlaybackRate(playbackRate) }, seek(time) { @@ -384,7 +385,7 @@ export default { libraryItem: session.libraryItem, episodeId: session.episodeId }) - this.playerHandler.prepareOpenSession(session, this.initialPlaybackRate) + this.playerHandler.prepareOpenSession(session, this.currentPlaybackRate) }, streamOpen(session) { console.log(`[StreamContainer] Stream session open`, session) @@ -451,7 +452,7 @@ export default { if (this.$refs.audioPlayer) this.$refs.audioPlayer.checkUpdateChapterTrack() }) - this.playerHandler.load(libraryItem, episodeId, true, this.initialPlaybackRate, payload.startTime) + this.playerHandler.load(libraryItem, episodeId, true, this.currentPlaybackRate, payload.startTime) }, pauseItem() { this.playerHandler.pause() diff --git a/client/components/modals/ChaptersModal.vue b/client/components/modals/ChaptersModal.vue index 2a3631db..2ace9891 100644 --- a/client/components/modals/ChaptersModal.vue +++ b/client/components/modals/ChaptersModal.vue @@ -2,13 +2,13 @@
@@ -92,6 +92,11 @@ export default { useChapterTrack: false } }, + watch: { + playbackRate() { + this.updateTimestamp() + } + }, computed: { sleepTimerRemainingString() { var rounded = Math.round(this.sleepTimerRemaining) @@ -289,14 +294,13 @@ export default { if (this.$refs.trackbar) this.$refs.trackbar.setPercentageReady(percentageReady) }, updateTimestamp() { - var ts = this.$refs.currentTimestamp + const ts = this.$refs.currentTimestamp if (!ts) { console.error('No timestamp el') return } const time = this.useChapterTrack ? Math.max(0, this.currentTime - this.currentChapterStart) : this.currentTime - var currTimeClean = this.$secondsToTimestamp(time) - ts.innerText = currTimeClean + ts.innerText = this.$secondsToTimestamp(time / this.playbackRate) }, setBufferTime(bufferTime) { if (this.$refs.trackbar) this.$refs.trackbar.setBufferTime(bufferTime)