From a12d94f30d7a21af5f5743996d353bec37479d56 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 30 Oct 2023 11:04:26 +0100 Subject: [PATCH] Fix live start time Use undefined to not break live edge position set by hls.js --- .../app/+videos/+video-watch/video-watch.component.ts | 2 ++ .../src/assets/player/shared/peertube/peertube-plugin.ts | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/client/src/app/+videos/+video-watch/video-watch.component.ts b/client/src/app/+videos/+video-watch/video-watch.component.ts index 2524d0216..5485b3ec5 100644 --- a/client/src/app/+videos/+video-watch/video-watch.component.ts +++ b/client/src/app/+videos/+video-watch/video-watch.component.ts @@ -695,6 +695,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy { } const getStartTime = () => { + if (video.isLive) return undefined + const byUrl = urlOptions.startTime !== undefined const byHistory = video.userHistory && (!this.playlist || urlOptions.resume !== undefined) const byLocalStorage = getStoredVideoWatchHistory(video.uuid) diff --git a/client/src/assets/player/shared/peertube/peertube-plugin.ts b/client/src/assets/player/shared/peertube/peertube-plugin.ts index a63053242..0ca5a500a 100644 --- a/client/src/assets/player/shared/peertube/peertube-plugin.ts +++ b/client/src/assets/player/shared/peertube/peertube-plugin.ts @@ -409,10 +409,13 @@ class PeerTubePlugin extends Plugin { // Prefer canplaythrough instead of canplay because Chrome has issues with the second one this.player.one('canplaythrough', () => { - const startTime = this.options.startTime() || 0 - debugLogger('Start the video at ' + startTime) + const startTime = this.options.startTime() - this.player.currentTime(timeToInt(startTime)) + if (startTime !== null && startTime !== undefined) { + debugLogger('Start the video at ' + startTime) + + this.player.currentTime(timeToInt(startTime)) + } if (this.options.stopTime()) { const stopTime = timeToInt(this.options.stopTime())