]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts
Remove thumbnail flash for autoplay
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-custom-markup / peertube-custom-tags / video-miniature-markup.component.ts
CommitLineData
8b61dcaf 1import { finalize } from 'rxjs/operators'
0ca454e3 2import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
8b61dcaf 3import { AuthService, Notifier } from '@app/core'
8ee25e17
C
4import { Video, VideoService } from '../../shared-main'
5import { MiniatureDisplayOptions } from '../../shared-video-miniature'
0ca454e3 6import { CustomMarkupComponent } from './shared'
2539932e
C
7
8/*
9 * Markup component that creates a video miniature only
10*/
11
12@Component({
13 selector: 'my-video-miniature-markup',
14 templateUrl: 'video-miniature-markup.component.html',
15 styleUrls: [ 'video-miniature-markup.component.scss' ]
16})
0ca454e3 17export class VideoMiniatureMarkupComponent implements CustomMarkupComponent, OnInit {
2539932e 18 @Input() uuid: string
9105634f 19 @Input() onlyDisplayTitle: boolean
2539932e 20
0ca454e3
C
21 @Output() loaded = new EventEmitter<boolean>()
22
2539932e
C
23 video: Video
24
25 displayOptions: MiniatureDisplayOptions = {
26 date: true,
27 views: true,
28 by: true,
29 avatar: false,
30 privacyLabel: false,
31 privacyText: false,
32 state: false,
33 blacklistInfo: false
34 }
35
36 constructor (
37 private auth: AuthService,
8b61dcaf
C
38 private videoService: VideoService,
39 private notifier: Notifier
2539932e
C
40 ) { }
41
42 getUser () {
43 return this.auth.getUser()
44 }
45
46 ngOnInit () {
9105634f
C
47 if (this.onlyDisplayTitle) {
48 for (const key of Object.keys(this.displayOptions)) {
49 this.displayOptions[key] = false
50 }
51 }
52
2539932e 53 this.videoService.getVideo({ videoId: this.uuid })
8b61dcaf
C
54 .pipe(finalize(() => this.loaded.emit(true)))
55 .subscribe(
56 video => this.video = video,
0ca454e3 57
8b61dcaf
C
58 err => this.notifier.error('Error in video miniature component: ' + err.message)
59 )
2539932e
C
60 }
61}