From 6e46de095d7169355dd83030f6ce4a582304153a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 5 Oct 2018 11:15:06 +0200 Subject: Add user history and resume videos --- client/src/app/shared/video/video-thumbnail.component.html | 10 ++++++---- client/src/app/shared/video/video-thumbnail.component.scss | 13 +++++++++++++ client/src/app/shared/video/video-thumbnail.component.ts | 8 ++++++++ client/src/app/shared/video/video.model.ts | 6 ++++++ client/src/app/shared/video/video.service.ts | 4 ++++ 5 files changed, 37 insertions(+), 4 deletions(-) (limited to 'client/src/app/shared') diff --git a/client/src/app/shared/video/video-thumbnail.component.html b/client/src/app/shared/video/video-thumbnail.component.html index c1d45ea18..d25666916 100644 --- a/client/src/app/shared/video/video-thumbnail.component.html +++ b/client/src/app/shared/video/video-thumbnail.component.html @@ -2,9 +2,11 @@ [routerLink]="['/videos/watch', video.uuid]" [attr.title]="video.name" class="video-thumbnail" > - + -
- {{ video.durationLabel }} -
+
{{ video.durationLabel }}
+ +
+
+
diff --git a/client/src/app/shared/video/video-thumbnail.component.scss b/client/src/app/shared/video/video-thumbnail.component.scss index 1dd8e5338..4772edaf0 100644 --- a/client/src/app/shared/video/video-thumbnail.component.scss +++ b/client/src/app/shared/video/video-thumbnail.component.scss @@ -29,6 +29,19 @@ } } + .progress-bar { + height: 3px; + width: 100%; + position: relative; + top: -3px; + background-color: rgba(0, 0, 0, 0.20); + + div { + height: 100%; + background-color: var(--mainColor); + } + } + .video-thumbnail-overlay { position: absolute; right: 5px; diff --git a/client/src/app/shared/video/video-thumbnail.component.ts b/client/src/app/shared/video/video-thumbnail.component.ts index 86d8f6f74..ca43700c7 100644 --- a/client/src/app/shared/video/video-thumbnail.component.ts +++ b/client/src/app/shared/video/video-thumbnail.component.ts @@ -22,4 +22,12 @@ export class VideoThumbnailComponent { return this.video.thumbnailUrl } + + getProgressPercent () { + if (!this.video.userHistory) return 0 + + const currentTime = this.video.userHistory.currentTime + + return (currentTime / this.video.duration) * 100 + } } diff --git a/client/src/app/shared/video/video.model.ts b/client/src/app/shared/video/video.model.ts index 80794faa6..b92c96450 100644 --- a/client/src/app/shared/video/video.model.ts +++ b/client/src/app/shared/video/video.model.ts @@ -66,6 +66,10 @@ export class Video implements VideoServerModel { avatar: Avatar } + userHistory?: { + currentTime: number + } + static buildClientUrl (videoUUID: string) { return '/videos/watch/' + videoUUID } @@ -116,6 +120,8 @@ export class Video implements VideoServerModel { this.blacklisted = hash.blacklisted this.blacklistedReason = hash.blacklistedReason + + this.userHistory = hash.userHistory } isVideoNSFWForUser (user: User, serverConfig: ServerConfig) { diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts index 2255a18a2..724a0bde9 100644 --- a/client/src/app/shared/video/video.service.ts +++ b/client/src/app/shared/video/video.service.ts @@ -58,6 +58,10 @@ export class VideoService implements VideosProvider { return VideoService.BASE_VIDEO_URL + uuid + '/views' } + getUserWatchingVideoUrl (uuid: string) { + return VideoService.BASE_VIDEO_URL + uuid + '/watching' + } + getVideo (uuid: string): Observable { return this.serverService.localeObservable .pipe( -- cgit v1.2.3