From 049f50bc3240b088b4f6c1cd9e3cf21675713d17 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 27 Oct 2023 14:29:40 +0200 Subject: [PATCH] Fix start time with web video player --- client/src/assets/player/peertube-player.ts | 3 +-- .../src/assets/player/shared/peertube/peertube-plugin.ts | 7 +++---- .../player-options-builder/web-video-options-builder.ts | 4 +--- client/src/assets/player/types/peertube-videojs-typings.ts | 1 - 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/client/src/assets/player/peertube-player.ts b/client/src/assets/player/peertube-player.ts index 192b2e124..857b9bd62 100644 --- a/client/src/assets/player/peertube-player.ts +++ b/client/src/assets/player/peertube-player.ts @@ -168,8 +168,7 @@ export class PeerTubePlayer { const webVideoOptionsBuilder = new WebVideoOptionsBuilder(pick(this.currentLoadOptions, [ 'videoFileToken', 'webVideo', - 'hls', - 'startTime' + 'hls' ])) this.player.webVideo(webVideoOptionsBuilder.getPluginOptions()) diff --git a/client/src/assets/player/shared/peertube/peertube-plugin.ts b/client/src/assets/player/shared/peertube/peertube-plugin.ts index 7aeae2670..a63053242 100644 --- a/client/src/assets/player/shared/peertube/peertube-plugin.ts +++ b/client/src/assets/player/shared/peertube/peertube-plugin.ts @@ -409,11 +409,10 @@ class PeerTubePlugin extends Plugin { // Prefer canplaythrough instead of canplay because Chrome has issues with the second one this.player.one('canplaythrough', () => { - if (this.options.startTime()) { - debugLogger('Start the video at ' + this.options.startTime()) + const startTime = this.options.startTime() || 0 + debugLogger('Start the video at ' + startTime) - this.player.currentTime(timeToInt(this.options.startTime())) - } + this.player.currentTime(timeToInt(startTime)) if (this.options.stopTime()) { const stopTime = timeToInt(this.options.stopTime()) diff --git a/client/src/assets/player/shared/player-options-builder/web-video-options-builder.ts b/client/src/assets/player/shared/player-options-builder/web-video-options-builder.ts index a3c3c3f27..6c1fb8f18 100644 --- a/client/src/assets/player/shared/player-options-builder/web-video-options-builder.ts +++ b/client/src/assets/player/shared/player-options-builder/web-video-options-builder.ts @@ -14,9 +14,7 @@ export class WebVideoOptionsBuilder { videoFiles: this.options.webVideo.videoFiles.length !== 0 ? this.options.webVideo.videoFiles - : this.options?.hls.videoFiles || [], - - startTime: this.options.startTime + : this.options?.hls.videoFiles || [] } } } diff --git a/client/src/assets/player/types/peertube-videojs-typings.ts b/client/src/assets/player/types/peertube-videojs-typings.ts index 6293404ab..108a1035d 100644 --- a/client/src/assets/player/types/peertube-videojs-typings.ts +++ b/client/src/assets/player/types/peertube-videojs-typings.ts @@ -191,7 +191,6 @@ type TheaterButtonOptions = { type WebVideoPluginOptions = { videoFiles: VideoFile[] - startTime: number | string videoFileToken: () => string }