X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Bvideos%2F%2Bvideo-watch%2Fvideo-watch.component.ts;h=10782682424b03445b668724c5aa50ef8dce7166;hb=e771e82dfac5f8cd5462fecf6618f9b1fb314e30;hp=2216bdd4a194072b0b2d35ff21ba4c01cbfa4577;hpb=e8bb5b6b3a1e4c2aeab368f01cc5092d8478b893;p=github%2FChocobozzz%2FPeerTube.git 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 2216bdd4a..107826824 100644 --- a/client/src/app/+videos/+video-watch/video-watch.component.ts +++ b/client/src/app/+videos/+video-watch/video-watch.component.ts @@ -188,7 +188,18 @@ export class VideoWatchComponent implements OnInit, OnDestroy { }) this.queryParamsSub = this.route.queryParams.subscribe(queryParams => { - this.playlistPosition = queryParams[ 'playlistPosition' ] + // Handle the ?playlistPosition + const positionParam = queryParams[ 'playlistPosition' ] + + this.playlistPosition = positionParam === 'last' + ? -1 // Handle the "last" index + : parseInt(positionParam, 10) + + if (isNaN(this.playlistPosition)) { + console.error(`playlistPosition query param '${positionParam}' was parsed as NaN, defaulting to 1.`) + this.playlistPosition = 1 + } + this.videoWatchPlaylist.updatePlaylistIndex(this.playlistPosition) const start = queryParams[ 'start' ] @@ -795,19 +806,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy { src: environment.apiUrl + c.captionPath })) - const playlistOptions = this.playlist - ? { - createComponent: false, - - playlist: this.playlist, - - getCurrentPosition: () => this.playlistPosition, - - embedUrl: this.playlist.embedUrl, - embedTitle: this.playlist.displayName - } - : undefined - const options: PeertubePlayerManagerOptions = { common: { autoplay: this.isAutoplay(), @@ -852,9 +850,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { videoCaptions: playerCaptions, - videoUUID: video.uuid, - - playlist: playlistOptions + videoUUID: video.uuid }, webtorrent: { @@ -862,6 +858,13 @@ export class VideoWatchComponent implements OnInit, OnDestroy { } } + // Only set this if we're in a playlist + if (this.playlist) { + options.common.previousVideo = () => { + this.zone.run(() => this.videoWatchPlaylist.navigateToPreviousPlaylistVideo()) + } + } + let mode: PlayerMode if (urlOptions.playerMode) {