1 import { Component, EventEmitter, Input, Output } from '@angular/core'
2 import { ScreenService } from '@app/core'
3 import { Video } from '../shared-main'
6 selector: 'my-video-thumbnail',
7 styleUrls: [ './video-thumbnail.component.scss' ],
8 templateUrl: './video-thumbnail.component.html'
10 export class VideoThumbnailComponent {
14 @Input() videoRouterLink: any[]
15 @Input() queryParams: { [ p: string ]: any }
16 @Input() videoHref: string
17 @Input() videoTarget: string
19 @Input() displayWatchLaterPlaylist: boolean
20 @Input() inWatchLaterPlaylist: boolean
22 @Output() watchLaterClick = new EventEmitter<boolean>()
24 addToWatchLaterText: string
25 addedToWatchLaterText: string
27 constructor (private screenService: ScreenService) {
28 this.addToWatchLaterText = $localize`Add to watch later`
29 this.addedToWatchLaterText = $localize`Remove from watch later`
33 if (!this.video) return ''
35 if (this.screenService.isInMobileView()) {
36 return this.video.previewUrl
39 return this.video.thumbnailUrl
42 getProgressPercent () {
43 if (!this.video.userHistory) return 0
45 const currentTime = this.video.userHistory.currentTime
47 return (currentTime / this.video.duration) * 100
50 getVideoRouterLink () {
51 if (this.videoRouterLink) return this.videoRouterLink
53 return [ '/videos/watch', this.video.uuid ]
56 onWatchLaterClick (event: Event) {
57 this.watchLaterClick.emit(this.inWatchLaterPlaylist)
59 event.stopPropagation()