From f1058b80050dcb0797fd171b0bffdcbc7cf0a05f Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Thu, 23 Nov 2023 19:08:52 +0000 Subject: [PATCH] Fix issues with initial start time. Closes #3151 --- src/components/VideoPlayer.vue | 56 ++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/src/components/VideoPlayer.vue b/src/components/VideoPlayer.vue index 0db8faad..f67045bb 100644 --- a/src/components/VideoPlayer.vue +++ b/src/components/VideoPlayer.vue @@ -244,32 +244,6 @@ export default { videoEl.setAttribute("poster", this.video.thumbnailUrl); - const time = this.$route.query.t ?? this.$route.query.start; - - if (time) { - videoEl.currentTime = parseTimeParam(time); - this.initialSeekComplete = true; - } else if (window.db && this.getPreferenceBoolean("watchHistory", false)) { - var tx = window.db.transaction("watch_history", "readonly"); - var store = tx.objectStore("watch_history"); - var request = store.get(this.video.id); - request.onsuccess = function (event) { - var video = event.target.result; - const currentTime = video?.currentTime; - if (currentTime) { - if (currentTime < component.video.duration * 0.9) { - videoEl.currentTime = currentTime; - } - } - }; - - tx.oncomplete = () => { - this.initialSeekComplete = true; - }; - } else { - this.initialSeekComplete = true; - } - const noPrevPlayer = !this.$player; var streams = []; @@ -520,8 +494,36 @@ export default { quality > 0 && (this.video.audioStreams.length > 0 || this.video.livestream) && !disableVideo; if (qualityConds) this.$player.configure("abr.enabled", false); + const time = this.$route.query.t ?? this.$route.query.start; + + var startTime = 0; + + if (time) { + startTime = parseTimeParam(time); + this.initialSeekComplete = true; + } else if (window.db && this.getPreferenceBoolean("watchHistory", false)) { + var tx = window.db.transaction("watch_history", "readonly"); + var store = tx.objectStore("watch_history"); + var request = store.get(this.video.id); + request.onsuccess = function (event) { + var video = event.target.result; + const currentTime = video?.currentTime; + if (currentTime) { + if (currentTime < video.duration * 0.9) { + startTime = currentTime; + } + } + }; + + tx.oncomplete = () => { + this.initialSeekComplete = true; + }; + } else { + this.initialSeekComplete = true; + } + player - .load(uri, 0, mime) + .load(uri, startTime, mime) .then(() => { const isSafari = window.navigator?.vendor?.includes("Apple");