From 167d36df631fd0fb1ab013eaacb8bcfcdfbfa910 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 19 Mar 2024 11:29:04 +0100 Subject: [PATCH] Fix playlist start time of element 1 --- .../shared/playlist/video-watch-playlist.component.ts | 1 + .../src/app/+videos/+video-watch/video-watch.component.ts | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/client/src/app/+videos/+video-watch/shared/playlist/video-watch-playlist.component.ts b/client/src/app/+videos/+video-watch/shared/playlist/video-watch-playlist.component.ts index 70e040b2b..1bb186929 100644 --- a/client/src/app/+videos/+video-watch/shared/playlist/video-watch-playlist.component.ts +++ b/client/src/app/+videos/+video-watch/shared/playlist/video-watch-playlist.component.ts @@ -118,6 +118,7 @@ export class VideoWatchPlaylistComponent { if (position) this.updatePlaylistIndex(position) if (redirectToFirst) { + console.log(firstAvailableVideo) const extras = { queryParams: { start: firstAvailableVideo.startTimestamp, 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 daa5cdfcf..e68fd91f7 100644 --- a/client/src/app/+videos/+video-watch/video-watch.component.ts +++ b/client/src/app/+videos/+video-watch/video-watch.component.ts @@ -293,7 +293,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy { private loadRouteQuery () { this.queryParamsSub = this.route.queryParams.subscribe(queryParams => { // Handle the ?playlistPosition - const positionParam = queryParams['playlistPosition'] ?? 1 + const positionParam = queryParams['playlistPosition'] + if (!positionParam) return this.playlistPosition = positionParam === 'last' ? -1 // Handle the "last" index @@ -307,7 +308,9 @@ export class VideoWatchComponent implements OnInit, OnDestroy { this.videoWatchPlaylist.updatePlaylistIndex(this.playlistPosition) const start = queryParams['start'] - if (this.peertubePlayer && start) this.peertubePlayer.getPlayer().currentTime(parseInt(start, 10)) + if (this.peertubePlayer?.getPlayer() && start) { + this.peertubePlayer.getPlayer().currentTime(parseInt(start, 10)) + } }) }