From 6de076222aca7005371e01768171efdc62ed8018 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sat, 25 Feb 2023 16:18:28 +0100 Subject: Avoid always resuming the end of the video --- .../app/+videos/+video-watch/video-watch.component.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'client/src/app') 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 84548de97..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, @@ -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 - let startTime = getStartTime() + // If we are at the end of the video, reset the timer + if (video.duration - startTime <= 1) startTime = 0 + + 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, -- cgit v1.2.3