Skip to content

Commit

Permalink
Fix video start time handling (#5719)
Browse files Browse the repository at this point in the history
  • Loading branch information
absidue committed Sep 21, 2024
1 parent fa4886e commit 9ca2c74
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
42 changes: 20 additions & 22 deletions src/renderer/views/Watch/Watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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() {
Expand All @@ -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) {
Expand All @@ -279,7 +295,6 @@ export default defineComponent({
this.activeFormat = this.defaultVideoFormat

this.checkIfTimestamp()
this.setStartTime()
},
mounted: function () {
this.onMountedDependOnLocalStateLoading()
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9ca2c74

Please sign in to comment.