From 58b9ce3080c12678e8c1c28c08da09d6ea60011d Mon Sep 17 00:00:00 2001 From: kontrollanten <6680299+kontrollanten@users.noreply.github.com> Date: Wed, 31 Mar 2021 11:26:32 +0200 Subject: Resume videos for non-logged in users (#3885) * client: resume videos for non-logged in users closes #3866 * fix build for embeded * Update client/src/app/app.component.ts * fix review comments --- client/src/app/+videos/+video-watch/video-watch.component.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 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 571d1e99a..075f70f56 100644 --- a/client/src/app/+videos/+video-watch/video-watch.component.ts +++ b/client/src/app/+videos/+video-watch/video-watch.component.ts @@ -29,7 +29,7 @@ import { MetaService } from '@ngx-meta/core' import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' import { ServerConfig, ServerErrorCode, UserVideoRateType, VideoCaption, VideoPrivacy, VideoState } from '@shared/models' -import { getStoredP2PEnabled, getStoredTheater } from '../../../assets/player/peertube-player-local-storage' +import { cleanupVideoWatch, getStoredP2PEnabled, getStoredTheater, getStoredVideoWatchHistory } from '../../../assets/player/peertube-player-local-storage' import { CustomizationOptions, P2PMediaLoaderOptions, @@ -195,6 +195,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy { this.theaterEnabled = getStoredTheater() this.hooks.runAction('action:video-watch.init', 'video-watch') + + setTimeout(cleanupVideoWatch, 1500) // Run in timeout to ensure we're not blocking the UI } ngOnDestroy () { @@ -768,9 +770,11 @@ export class VideoWatchComponent implements OnInit, OnDestroy { const getStartTime = () => { const byUrl = urlOptions.startTime !== undefined const byHistory = video.userHistory && (!this.playlist || urlOptions.resume !== undefined) + const byLocalStorage = getStoredVideoWatchHistory(video.uuid) if (byUrl) return timeToInt(urlOptions.startTime) if (byHistory) return video.userHistory.currentTime + if (byLocalStorage) return byLocalStorage.duration return 0 } @@ -828,7 +832,9 @@ export class VideoWatchComponent implements OnInit, OnDestroy { serverUrl: environment.apiUrl, - videoCaptions: playerCaptions + videoCaptions: playerCaptions, + + videoUUID: video.uuid }, webtorrent: { -- cgit v1.2.3