})
this.queryParamsSub = this.route.queryParams.subscribe(queryParams => {
- this.playlistPosition = queryParams[ 'playlistPosition' ]
+ // Handle the ?playlistPosition
+ const positionParam = queryParams[ 'playlistPosition' ] ?? 1
+
+ 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' ]
this.player.one('ended', () => {
if (this.video.isLive) {
- this.video.state.id = VideoState.LIVE_ENDED
+ this.zone.run(() => this.video.state.id = VideoState.LIVE_ENDED)
}
})
common: {
autoplay: this.isAutoplay(),
nextVideo: () => this.zone.run(() => this.autoplayNext()),
- previousVideo: () => this.zone.run(() => {
- // FIXME: Only show if this is a playlist
- if (this.playlist) this.zone.run(() => this.videoWatchPlaylist.navigateToPreviousPlaylistVideo())
- }),
playerElement: this.playerElement,
onPlayerElementChange: (element: HTMLVideoElement) => this.playerElement = element,
}
}
+ // 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) {