diff options
Diffstat (limited to 'client/src/app/videos/+video-watch/video-watch.component.ts')
-rw-r--r-- | client/src/app/videos/+video-watch/video-watch.component.ts | 16 |
1 files changed, 14 insertions, 2 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 bad0144bf..dcceb1400 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts | |||
@@ -37,7 +37,7 @@ import { PluginService } from '@app/core/plugins/plugin.service' | |||
37 | import { HooksService } from '@app/core/plugins/hooks.service' | 37 | import { HooksService } from '@app/core/plugins/hooks.service' |
38 | import { PlatformLocation } from '@angular/common' | 38 | import { PlatformLocation } from '@angular/common' |
39 | import { RecommendedVideosComponent } from '../recommendations/recommended-videos.component' | 39 | import { RecommendedVideosComponent } from '../recommendations/recommended-videos.component' |
40 | import { scrollToTop } from '@app/shared/misc/utils' | 40 | import { scrollToTop, isInViewport, isXPercentInViewport } from '@app/shared/misc/utils' |
41 | 41 | ||
42 | @Component({ | 42 | @Component({ |
43 | selector: 'my-video-watch', | 43 | selector: 'my-video-watch', |
@@ -478,12 +478,18 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
478 | 478 | ||
479 | /** | 479 | /** |
480 | * replaces this.player.one('ended') | 480 | * replaces this.player.one('ended') |
481 | * define 'condition(next)' to return true to wait, false to stop | 481 | * 'condition()': true to make the upnext functionality trigger, |
482 | * false to disable the upnext functionality | ||
483 | * go to the next video in 'condition()' if you don't want of the timer. | ||
484 | * 'next': function triggered at the end of the timer. | ||
485 | * 'suspended': function used at each clic of the timer checking if we need | ||
486 | * to reset progress and wait until 'suspended' becomes truthy again. | ||
482 | */ | 487 | */ |
483 | this.player.upnext({ | 488 | this.player.upnext({ |
484 | timeout: 10000, // 10s | 489 | timeout: 10000, // 10s |
485 | headText: this.i18n('Up Next'), | 490 | headText: this.i18n('Up Next'), |
486 | cancelText: this.i18n('Cancel'), | 491 | cancelText: this.i18n('Cancel'), |
492 | suspendedText: this.i18n('Autoplay is suspended'), | ||
487 | getTitle: () => this.nextVideoTitle, | 493 | getTitle: () => this.nextVideoTitle, |
488 | next: () => this.zone.run(() => this.autoplayNext()), | 494 | next: () => this.zone.run(() => this.autoplayNext()), |
489 | condition: () => { | 495 | condition: () => { |
@@ -496,6 +502,12 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
496 | return true // upnext will trigger | 502 | return true // upnext will trigger |
497 | } | 503 | } |
498 | return false // upnext will not trigger, and instead leave the video stopping | 504 | return false // upnext will not trigger, and instead leave the video stopping |
505 | }, | ||
506 | suspended: () => { | ||
507 | return ( | ||
508 | !isXPercentInViewport(this.player.el(), 80) || | ||
509 | !document.getElementById('content').contains(document.activeElement) | ||
510 | ) | ||
499 | } | 511 | } |
500 | }) | 512 | }) |
501 | 513 | ||