X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Bvideos%2F%2Bvideo-watch%2Fvideo-watch.component.ts;h=19ad97d42a2a4e6dbd32b7e8fcfd6dd78ef3b3fe;hb=6de076222aca7005371e01768171efdc62ed8018;hp=fa04178321ee9798269ffee2aa43e6ac6e5e2c10;hpb=0e08a5e7492498a8c43c94277e6c3f311da8fa53;p=github%2FChocobozzz%2FPeerTube.git 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 fa0417832..19ad97d42 100644 --- a/client/src/app/+videos/+video-watch/video-watch.component.ts +++ b/client/src/app/+videos/+video-watch/video-watch.component.ts @@ -91,6 +91,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy { private hotkeys: Hotkey[] = [] + private static VIEW_VIDEO_INTERVAL_MS = 5000 + constructor ( private elementRef: ElementRef, private route: ActivatedRoute, @@ -133,8 +135,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy { this.loadRouteParams() this.loadRouteQuery() - this.initHotkeys() - this.theaterEnabled = getStoredTheater() this.hooks.runAction('action:video-watch.init', 'video-watch') @@ -407,6 +407,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy { if (res === false) return this.location.back() } + this.buildHotkeysHelp(video) + this.buildPlayer({ urlOptions, loggedInOrAnonymousUser, forceAutoplay }) .catch(err => logger.error('Cannot build the player', err)) @@ -613,16 +615,18 @@ export class VideoWatchComponent implements OnInit, OnDestroy { const byLocalStorage = getStoredVideoWatchHistory(video.uuid) if (byUrl) return timeToInt(urlOptions.startTime) - if (byHistory) return video.userHistory.currentTime - if (byLocalStorage) return byLocalStorage.duration - return 0 - } + let startTime = 0 + if (byHistory) startTime = video.userHistory.currentTime + if (byLocalStorage) startTime = byLocalStorage.duration + + // If we are at the end of the video, reset the timer + if (video.duration - startTime <= 1) startTime = 0 - let startTime = getStartTime() + return startTime + } - // If we are at the end of the video, reset the timer - if (video.duration - startTime <= 1) startTime = 0 + const startTime = getStartTime() const playerCaptions = videoCaptions.map(c => ({ label: c.language.label, @@ -679,6 +683,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { videoViewUrl: video.privacy.id !== VideoPrivacy.PRIVATE ? this.videoService.getVideoViewUrl(video.uuid) : null, + videoViewIntervalMs: VideoWatchComponent.VIEW_VIDEO_INTERVAL_MS, authorizationHeader: () => this.authService.getRequestHeaderValue(), serverUrl: environment.originServerUrl || window.location.origin, @@ -787,33 +792,43 @@ export class VideoWatchComponent implements OnInit, OnDestroy { this.video.viewers = newViewers } - private initHotkeys () { + private buildHotkeysHelp (video: Video) { + if (this.hotkeys.length !== 0) { + this.hotkeysService.remove(this.hotkeys) + } + this.hotkeys = [ // These hotkeys are managed by the player new Hotkey('f', e => e, undefined, $localize`Enter/exit fullscreen`), new Hotkey('space', e => e, undefined, $localize`Play/Pause the video`), new Hotkey('m', e => e, undefined, $localize`Mute/unmute the video`), - new Hotkey('0-9', e => e, undefined, $localize`Skip to a percentage of the video: 0 is 0% and 9 is 90%`), - new Hotkey('up', e => e, undefined, $localize`Increase the volume`), new Hotkey('down', e => e, undefined, $localize`Decrease the volume`), - new Hotkey('right', e => e, undefined, $localize`Seek the video forward`), - new Hotkey('left', e => e, undefined, $localize`Seek the video backward`), - - new Hotkey('>', e => e, undefined, $localize`Increase playback rate`), - new Hotkey('<', e => e, undefined, $localize`Decrease playback rate`), - - new Hotkey(',', e => e, undefined, $localize`Navigate in the video to the previous frame`), - new Hotkey('.', e => e, undefined, $localize`Navigate in the video to the next frame`), - new Hotkey('t', e => { this.theaterEnabled = !this.theaterEnabled return false }, undefined, $localize`Toggle theater mode`) ] + if (!video.isLive) { + this.hotkeys = this.hotkeys.concat([ + // These hotkeys are also managed by the player but only for VOD + + new Hotkey('0-9', e => e, undefined, $localize`Skip to a percentage of the video: 0 is 0% and 9 is 90%`), + + new Hotkey('right', e => e, undefined, $localize`Seek the video forward`), + new Hotkey('left', e => e, undefined, $localize`Seek the video backward`), + + new Hotkey('>', e => e, undefined, $localize`Increase playback rate`), + new Hotkey('<', e => e, undefined, $localize`Decrease playback rate`), + + new Hotkey(',', e => e, undefined, $localize`Navigate in the video to the previous frame`), + new Hotkey('.', e => e, undefined, $localize`Navigate in the video to the next frame`) + ]) + } + if (this.isUserLoggedIn()) { this.hotkeys = this.hotkeys.concat([ new Hotkey('shift+s', () => {