})
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' ]
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(),
videoCaptions: playerCaptions,
- videoUUID: video.uuid,
-
- playlist: playlistOptions
+ videoUUID: video.uuid
},
webtorrent: {
}
}
+ // 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) {