1 import { Component, EventEmitter, Input, Output } from '@angular/core'
2 import { Video } from './video.model'
3 import { ScreenService } from '@app/shared/misc/screen.service'
4 import { I18n } from '@ngx-translate/i18n-polyfill'
7 selector: 'my-video-thumbnail',
8 styleUrls: [ './video-thumbnail.component.scss' ],
9 templateUrl: './video-thumbnail.component.html'
11 export class VideoThumbnailComponent {
14 @Input() routerLink: any[]
15 @Input() queryParams: any[]
17 @Input() displayWatchLaterPlaylist: boolean
18 @Input() inWatchLaterPlaylist: boolean
20 @Output() watchLaterClick = new EventEmitter<boolean>()
22 addToWatchLaterText: string
23 addedToWatchLaterText: string
26 private screenService: ScreenService,
29 this.addToWatchLaterText = this.i18n('Add to watch later')
30 this.addedToWatchLaterText = this.i18n('Remove from watch later')
34 if (!this.video) return ''
36 if (this.screenService.isInMobileView()) {
37 return this.video.previewUrl
40 return this.video.thumbnailUrl
43 getProgressPercent () {
44 if (!this.video.userHistory) return 0
46 const currentTime = this.video.userHistory.currentTime
48 return (currentTime / this.video.duration) * 100
51 getVideoRouterLink () {
52 if (this.routerLink) return this.routerLink
54 return [ '/videos/watch', this.video.uuid ]
57 onWatchLaterClick (event: Event) {
58 this.watchLaterClick.emit(this.inWatchLaterPlaylist)
60 event.stopPropagation()