]>
Commit | Line | Data |
---|---|---|
202f6b6c C |
1 | import { Component, Input } from '@angular/core' |
2 | import { Video } from './video.model' | |
bbe0f064 | 3 | import { ScreenService } from '@app/shared/misc/screen.service' |
202f6b6c C |
4 | |
5 | @Component({ | |
6 | selector: 'my-video-thumbnail', | |
7 | styleUrls: [ './video-thumbnail.component.scss' ], | |
8 | templateUrl: './video-thumbnail.component.html' | |
9 | }) | |
10 | export class VideoThumbnailComponent { | |
11 | @Input() video: Video | |
12 | @Input() nsfw = false | |
e2f01c47 C |
13 | @Input() routerLink: any[] |
14 | @Input() queryParams: any[] | |
3290f37c | 15 | |
e2f01c47 C |
16 | constructor (private screenService: ScreenService) { |
17 | } | |
bbe0f064 | 18 | |
3290f37c C |
19 | getImageUrl () { |
20 | if (!this.video) return '' | |
21 | ||
bbe0f064 | 22 | if (this.screenService.isInMobileView()) { |
3290f37c C |
23 | return this.video.previewUrl |
24 | } | |
25 | ||
26 | return this.video.thumbnailUrl | |
27 | } | |
6e46de09 C |
28 | |
29 | getProgressPercent () { | |
30 | if (!this.video.userHistory) return 0 | |
31 | ||
32 | const currentTime = this.video.userHistory.currentTime | |
33 | ||
34 | return (currentTime / this.video.duration) * 100 | |
35 | } | |
e2f01c47 C |
36 | |
37 | getVideoRouterLink () { | |
38 | if (this.routerLink) return this.routerLink | |
39 | ||
40 | return [ '/videos/watch', this.video.uuid ] | |
41 | } | |
202f6b6c | 42 | } |