- this.player.one('ended', () => {
- if (this.playlist) {
- if (
- this.user && this.user.autoPlayNextVideoPlaylist ||
- peertubeSessionStorage.getItem(VideoWatchPlaylistComponent.SESSION_STORAGE_AUTO_PLAY_NEXT_VIDEO_PLAYLIST) === 'true'
- ) this.zone.run(() => this.videoWatchPlaylist.navigateToNextPlaylistVideo())
- } else if (
- this.user && this.user.autoPlayNextVideo ||
- peertubeSessionStorage.getItem(RecommendedVideosComponent.SESSION_STORAGE_AUTO_PLAY_NEXT_VIDEO) === 'true'
- ) {
- this.zone.run(() => this.autoplayNext())
+ /**
+ * replaces this.player.one('ended')
+ * define 'condition(next)' to return true to wait, false to stop
+ */
+ this.player.upnext({
+ timeout: 10000, // 10s
+ headText: this.i18n('Up Next'),
+ cancelText: this.i18n('Cancel'),
+ getTitle: () => this.nextVideoTitle,
+ next: () => this.zone.run(() => this.autoplayNext()),
+ condition: () => {
+ if (this.playlist) {
+ if (this.isPlaylistAutoPlayEnabled()) {
+ // upnext will not trigger, and instead the next video will play immediately
+ this.zone.run(() => this.videoWatchPlaylist.navigateToNextPlaylistVideo())
+ }
+ } else if (this.isAutoPlayEnabled()) {
+ return true // upnext will trigger
+ }
+ return false // upnext will not trigger, and instead leave the video stopping