1 import { Component, EventEmitter, Input, Output } from '@angular/core'
2 import { ScreenService } from '@app/core'
3 import { VideoState } from '@shared/models'
4 import { Video } from '../shared-main'
7 selector: 'my-video-thumbnail',
8 styleUrls: [ './video-thumbnail.component.scss' ],
9 templateUrl: './video-thumbnail.component.html'
11 export class VideoThumbnailComponent {
15 @Input() videoRouterLink: any[]
16 @Input() queryParams: { [ p: string ]: any }
17 @Input() videoHref: string
18 @Input() videoTarget: string
20 @Input() displayWatchLaterPlaylist: boolean
21 @Input() inWatchLaterPlaylist: boolean
23 @Output() watchLaterClick = new EventEmitter<boolean>()
25 addToWatchLaterText: string
26 addedToWatchLaterText: string
28 constructor (private screenService: ScreenService) {
29 this.addToWatchLaterText = $localize`Add to watch later`
30 this.addedToWatchLaterText = $localize`Remove from watch later`
34 return this.video.state.id === VideoState.LIVE_ENDED
38 if (!this.video) return ''
40 if (this.screenService.isInMobileView()) {
41 return this.video.previewUrl
44 return this.video.thumbnailUrl
47 getProgressPercent () {
48 if (!this.video.userHistory) return 0
50 const currentTime = this.video.userHistory.currentTime
52 return (currentTime / this.video.duration) * 100
55 getVideoRouterLink () {
56 if (this.videoRouterLink) return this.videoRouterLink
58 return [ '/videos/watch', this.video.uuid ]
61 onWatchLaterClick (event: Event) {
62 this.watchLaterClick.emit(this.inWatchLaterPlaylist)
64 event.stopPropagation()