aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app')
-rw-r--r--client/src/app/videos/+video-watch/video-watch.component.ts33
1 files changed, 25 insertions, 8 deletions
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 3a7629cc6..50854c592 100644
--- a/client/src/app/videos/+video-watch/video-watch.component.ts
+++ b/client/src/app/videos/+video-watch/video-watch.component.ts
@@ -36,7 +36,6 @@ import { getStoredTheater } from '../../../assets/player/peertube-player-local-s
36import { PluginService } from '@app/core/plugins/plugin.service' 36import { PluginService } from '@app/core/plugins/plugin.service'
37import { HooksService } from '@app/core/plugins/hooks.service' 37import { HooksService } from '@app/core/plugins/hooks.service'
38import { PlatformLocation } from '@angular/common' 38import { PlatformLocation } from '@angular/common'
39import { randomInt } from '@shared/core-utils/miscs/miscs'
40import { RecommendedVideosComponent } from '../recommendations/recommended-videos.component' 39import { RecommendedVideosComponent } from '../recommendations/recommended-videos.component'
41import { scrollToTop } from '@app/shared/misc/utils' 40import { scrollToTop } from '@app/shared/misc/utils'
42 41
@@ -79,6 +78,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
79 tooltipSaveToPlaylist = '' 78 tooltipSaveToPlaylist = ''
80 79
81 private nextVideoUuid = '' 80 private nextVideoUuid = ''
81 private nextVideoTitle = ''
82 private currentTime: number 82 private currentTime: number
83 private paramsSub: Subscription 83 private paramsSub: Subscription
84 private queryParamsSub: Subscription 84 private queryParamsSub: Subscription
@@ -247,8 +247,10 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
247 247
248 onRecommendations (videos: Video[]) { 248 onRecommendations (videos: Video[]) {
249 if (videos.length > 0) { 249 if (videos.length > 0) {
250 // Pick a random video until the recommendations are improved 250 // The recommended videos's first element should be the next video
251 this.nextVideoUuid = videos[randomInt(0,videos.length - 1)].uuid 251 const video = videos[0]
252 this.nextVideoUuid = video.uuid
253 this.nextVideoTitle = video.name
252 } 254 }
253 } 255 }
254 256
@@ -468,11 +470,26 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
468 this.currentTime = Math.floor(this.player.currentTime()) 470 this.currentTime = Math.floor(this.player.currentTime())
469 }) 471 })
470 472
471 this.player.one('ended', () => { 473 /**
472 if (this.playlist) { 474 * replaces this.player.one('ended')
473 if (this.isPlaylistAutoPlayEnabled()) this.zone.run(() => this.videoWatchPlaylist.navigateToNextPlaylistVideo()) 475 * define 'condition(next)' to return true to wait, false to stop
474 } else if (this.isAutoPlayEnabled()) { 476 */
475 this.zone.run(() => this.autoplayNext()) 477 this.player.upnext({
478 timeout: 1000000,
479 headText: this.i18n('Up Next'),
480 cancelText: this.i18n('Cancel'),
481 getTitle: () => this.nextVideoTitle,
482 next: () => this.zone.run(() => this.autoplayNext()),
483 condition: () => {
484 if (this.playlist) {
485 if (this.isPlaylistAutoPlayEnabled()) {
486 // upnext will not trigger, and instead the next video will play immediately
487 this.zone.run(() => this.videoWatchPlaylist.navigateToNextPlaylistVideo())
488 }
489 } else if (this.isAutoPlayEnabled()) {
490 return true // upnext will trigger
491 }
492 return false // upnext will not trigger, and instead leave the video stopping
476 } 493 }
477 }) 494 })
478 495