From 9ca2c7452968e976896191d87281fe8eecf4fea1 Mon Sep 17 00:00:00 2001 From: absidue <48293849+absidue@users.noreply.github.com> Date: Sat, 21 Sep 2024 05:29:11 +0200 Subject: [PATCH] Fix video start time handling (#5719) --- .../ft-shaka-video-player.js | 12 ------ src/renderer/views/Watch/Watch.js | 42 +++++++++---------- 2 files changed, 20 insertions(+), 34 deletions(-) diff --git a/src/renderer/components/ft-shaka-video-player/ft-shaka-video-player.js b/src/renderer/components/ft-shaka-video-player/ft-shaka-video-player.js index 3828574691ef..e0afeb6c3762 100644 --- a/src/renderer/components/ft-shaka-video-player/ft-shaka-video-player.js +++ b/src/renderer/components/ft-shaka-video-player/ft-shaka-video-player.js @@ -2371,18 +2371,6 @@ export default defineComponent({ if (props.format !== 'legacy') { player.addEventListener('streaming', () => { - if (props.startTime !== null) { - if (player.isLive() || player.getManifestType() === 'HLS') { - player.updateStartTime(null) - } else { - const { end } = player.seekRange() - - if (props.startTime > (end - 10)) { - player.updateStartTime(end - 10) - } - } - } - hasMultipleAudioTracks.value = player.getAudioLanguagesAndRoles().length > 1 if (props.format === 'dash') { diff --git a/src/renderer/views/Watch/Watch.js b/src/renderer/views/Watch/Watch.js index d3bfa6fb2526..f5a29b77e661 100644 --- a/src/renderer/views/Watch/Watch.js +++ b/src/renderer/views/Watch/Watch.js @@ -113,8 +113,6 @@ export default defineComponent({ playlistItemId: null, /** @type {number|null} */ timestamp: null, - /** @type {number|null} */ - startTimeSeconds: null, playNextTimeout: null, playNextCountDownIntervalId: null, infoAreaSticky: true, @@ -232,6 +230,26 @@ export default defineComponent({ return this.$store.getters.getPlaylist(this.playlistId) }, + startTimeSeconds: function () { + if (this.isLoading || this.isLive) { + return null + } + + if (this.timestamp !== null && this.timestamp < this.videoLengthSeconds) { + return this.timestamp + } else if (this.saveWatchedProgress && this.historyEntryExists) { + // For UX consistency, no progress reading if writing disabled + + /** @type {number} */ + const watchProgress = this.historyEntry.watchProgress + + if (watchProgress > 0 && watchProgress < this.videoLengthSeconds - 2) { + return watchProgress + } + } + + return null + } }, watch: { async $route() { @@ -254,11 +272,9 @@ export default defineComponent({ this.vrProjection = null this.downloadLinks = [] this.videoCurrentChapterIndex = 0 - this.startTimeSeconds = null this.videoGenreIsMusic = false this.checkIfTimestamp() - this.setStartTime() this.checkIfPlaylist() switch (this.backendPreference) { @@ -279,7 +295,6 @@ export default defineComponent({ this.activeFormat = this.defaultVideoFormat this.checkIfTimestamp() - this.setStartTime() }, mounted: function () { this.onMountedDependOnLocalStateLoading() @@ -1069,23 +1084,6 @@ export default defineComponent({ } }, - setStartTime: function () { - if (this.timestamp !== null && this.timestamp > 0) { - this.startTimeSeconds = this.timestamp - return - } else if (this.saveWatchedProgress && this.historyEntryExists) { - // For UX consistency, no progress reading if writing disabled - const watchProgress = this.historyEntry.watchProgress - - if (watchProgress > 0) { - this.startTimeSeconds = watchProgress - return - } - } - - this.startTimeSeconds = null - }, - checkIfPlaylist: function () { // On the off chance that user selected pause on current video // Then clicks on another video in the playlist