From 3c6a44a18175b85d2a3e0b7c3e975718833e5345 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 18 Aug 2020 16:04:03 +0200 Subject: Fix video playlist resuming --- .../src/app/+videos/+video-watch/video-watch.component.ts | 14 +++++++------- .../video-add-to-playlist.component.ts | 10 ++++++++-- 2 files changed, 15 insertions(+), 9 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 fb89bf6cd..4df2c6c5e 100644 --- a/client/src/app/+videos/+video-watch/video-watch.component.ts +++ b/client/src/app/+videos/+video-watch/video-watch.component.ts @@ -362,6 +362,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy { const queryParams = this.route.snapshot.queryParams const urlOptions = { + resume: queryParams.resume, + startTime: queryParams.start, stopTime: queryParams.stop, @@ -657,16 +659,14 @@ export class VideoWatchComponent implements OnInit, OnDestroy { const byUrl = urlOptions.startTime !== undefined const byHistory = video.userHistory && (!this.playlist || urlOptions.resume !== undefined) - if (byUrl) { - return timeToInt(urlOptions.startTime) - } else if (byHistory) { - return video.userHistory.currentTime - } else { - return 0 - } + if (byUrl) return timeToInt(urlOptions.startTime) + if (byHistory) return video.userHistory.currentTime + + return 0 } let startTime = getStartTime() + // If we are at the end of the video, reset the timer if (video.duration - startTime <= 1) startTime = 0 diff --git a/client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts b/client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts index b6a3408c7..681e5becd 100644 --- a/client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts +++ b/client/src/app/shared/shared-video-playlist/video-add-to-playlist.component.ts @@ -4,11 +4,17 @@ import { debounceTime, filter } from 'rxjs/operators' import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core' import { AuthService, DisableForReuseHook, Notifier } from '@app/core' import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' -import { Video, VideoExistInPlaylist, VideoPlaylistCreate, VideoPlaylistElementCreate, VideoPlaylistPrivacy, VideoPlaylistElementUpdate } from '@shared/models' +import { + Video, + VideoExistInPlaylist, + VideoPlaylistCreate, + VideoPlaylistElementCreate, + VideoPlaylistElementUpdate, + VideoPlaylistPrivacy +} from '@shared/models' import { secondsToTime } from '../../../assets/player/utils' import { VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR } from '../form-validators/video-playlist-validators' import { CachedPlaylist, VideoPlaylistService } from './video-playlist.service' -import { invoke, last } from 'lodash' const logger = debug('peertube:playlists:VideoAddToPlaylistComponent') -- cgit v1.2.3