Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix video start time handling #5719

Merged
merged 1 commit into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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