diff options
Diffstat (limited to 'client/src/app')
6 files changed, 48 insertions, 6 deletions
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 @@ | |||
2 | [routerLink]="['/videos/watch', video.uuid]" [attr.title]="video.name" | 2 | [routerLink]="['/videos/watch', video.uuid]" [attr.title]="video.name" |
3 | class="video-thumbnail" | 3 | class="video-thumbnail" |
4 | > | 4 | > |
5 | <img alt="" [attr.aria-labelledby]="video.name" [attr.src]="getImageUrl()" [ngClass]="{ 'blur-filter': nsfw }" /> | 5 | <img alt="" [attr.aria-labelledby]="video.name" [attr.src]="getImageUrl()" [ngClass]="{ 'blur-filter': nsfw }" /> |
6 | 6 | ||
7 | <div class="video-thumbnail-overlay"> | 7 | <div class="video-thumbnail-overlay">{{ video.durationLabel }}</div> |
8 | {{ video.durationLabel }} | 8 | |
9 | </div> | 9 | <div class="progress-bar" *ngIf="video.userHistory?.currentTime"> |
10 | <div [ngStyle]="{ 'width.%': getProgressPercent() }"></div> | ||
11 | </div> | ||
10 | </a> | 12 | </a> |
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 @@ | |||
29 | } | 29 | } |
30 | } | 30 | } |
31 | 31 | ||
32 | .progress-bar { | ||
33 | height: 3px; | ||
34 | width: 100%; | ||
35 | position: relative; | ||
36 | top: -3px; | ||
37 | background-color: rgba(0, 0, 0, 0.20); | ||
38 | |||
39 | div { | ||
40 | height: 100%; | ||
41 | background-color: var(--mainColor); | ||
42 | } | ||
43 | } | ||
44 | |||
32 | .video-thumbnail-overlay { | 45 | .video-thumbnail-overlay { |
33 | position: absolute; | 46 | position: absolute; |
34 | right: 5px; | 47 | 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 { | |||
22 | 22 | ||
23 | return this.video.thumbnailUrl | 23 | return this.video.thumbnailUrl |
24 | } | 24 | } |
25 | |||
26 | getProgressPercent () { | ||
27 | if (!this.video.userHistory) return 0 | ||
28 | |||
29 | const currentTime = this.video.userHistory.currentTime | ||
30 | |||
31 | return (currentTime / this.video.duration) * 100 | ||
32 | } | ||
25 | } | 33 | } |
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 { | |||
66 | avatar: Avatar | 66 | avatar: Avatar |
67 | } | 67 | } |
68 | 68 | ||
69 | userHistory?: { | ||
70 | currentTime: number | ||
71 | } | ||
72 | |||
69 | static buildClientUrl (videoUUID: string) { | 73 | static buildClientUrl (videoUUID: string) { |
70 | return '/videos/watch/' + videoUUID | 74 | return '/videos/watch/' + videoUUID |
71 | } | 75 | } |
@@ -116,6 +120,8 @@ export class Video implements VideoServerModel { | |||
116 | 120 | ||
117 | this.blacklisted = hash.blacklisted | 121 | this.blacklisted = hash.blacklisted |
118 | this.blacklistedReason = hash.blacklistedReason | 122 | this.blacklistedReason = hash.blacklistedReason |
123 | |||
124 | this.userHistory = hash.userHistory | ||
119 | } | 125 | } |
120 | 126 | ||
121 | isVideoNSFWForUser (user: User, serverConfig: ServerConfig) { | 127 | 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 { | |||
58 | return VideoService.BASE_VIDEO_URL + uuid + '/views' | 58 | return VideoService.BASE_VIDEO_URL + uuid + '/views' |
59 | } | 59 | } |
60 | 60 | ||
61 | getUserWatchingVideoUrl (uuid: string) { | ||
62 | return VideoService.BASE_VIDEO_URL + uuid + '/watching' | ||
63 | } | ||
64 | |||
61 | getVideo (uuid: string): Observable<VideoDetails> { | 65 | getVideo (uuid: string): Observable<VideoDetails> { |
62 | return this.serverService.localeObservable | 66 | return this.serverService.localeObservable |
63 | .pipe( | 67 | .pipe( |
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 ea10b22ad..c5deddf05 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts | |||
@@ -369,7 +369,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
369 | ) | 369 | ) |
370 | } | 370 | } |
371 | 371 | ||
372 | private async onVideoFetched (video: VideoDetails, videoCaptions: VideoCaption[], startTime = 0) { | 372 | private async onVideoFetched (video: VideoDetails, videoCaptions: VideoCaption[], startTimeFromUrl: number) { |
373 | this.video = video | 373 | this.video = video |
374 | 374 | ||
375 | // Re init attributes | 375 | // Re init attributes |
@@ -377,6 +377,10 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
377 | this.completeDescriptionShown = false | 377 | this.completeDescriptionShown = false |
378 | this.remoteServerDown = false | 378 | this.remoteServerDown = false |
379 | 379 | ||
380 | let startTime = startTimeFromUrl || (this.video.userHistory ? this.video.userHistory.currentTime : 0) | ||
381 | // Don't start the video if we are at the end | ||
382 | if (this.video.duration - startTime <= 1) startTime = 0 | ||
383 | |||
380 | if (this.video.isVideoNSFWForUser(this.user, this.serverService.getConfig())) { | 384 | if (this.video.isVideoNSFWForUser(this.user, this.serverService.getConfig())) { |
381 | const res = await this.confirmService.confirm( | 385 | const res = await this.confirmService.confirm( |
382 | this.i18n('This video contains mature or explicit content. Are you sure you want to watch it?'), | 386 | this.i18n('This video contains mature or explicit content. Are you sure you want to watch it?'), |
@@ -414,7 +418,12 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
414 | poster: this.video.previewUrl, | 418 | poster: this.video.previewUrl, |
415 | startTime, | 419 | startTime, |
416 | theaterMode: true, | 420 | theaterMode: true, |
417 | language: this.localeId | 421 | language: this.localeId, |
422 | |||
423 | userWatching: this.user ? { | ||
424 | url: this.videoService.getUserWatchingVideoUrl(this.video.uuid), | ||
425 | authorizationHeader: this.authService.getRequestHeaderValue() | ||
426 | } : undefined | ||
418 | }) | 427 | }) |
419 | 428 | ||
420 | if (this.videojsLocaleLoaded === false) { | 429 | if (this.videojsLocaleLoaded === false) { |