aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-main/video/embed.component.ts
blob: 43e3501978c18576c5bb4f3614763a334bec0be2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { environment } from 'src/environments/environment'
import { Component, Input, OnInit } from '@angular/core'
import { DomSanitizer, SafeHtml } from '@angular/platform-browser'
import { buildVideoOrPlaylistEmbed } from '@root-helpers/video'
import { buildVideoEmbedLink, decorateVideoLink } from '@shared/core-utils'
import { Video } from '@shared/models'

@Component({
  selector: 'my-embed',
  styleUrls: [ './embed.component.scss' ],
  templateUrl: './embed.component.html'
})
export class EmbedComponent implements OnInit {
  @Input() video: Pick<Video, 'name' | 'uuid'>

  embedHTML: SafeHtml

  constructor (private sanitizer: DomSanitizer) {

  }

  ngOnInit () {
    const html = buildVideoOrPlaylistEmbed({
      embedUrl: decorateVideoLink({
        url: buildVideoEmbedLink(this.video, environment.originServerUrl),

        title: false,
        warningTitle: false
      }),
      embedTitle: this.video.name
    })

    this.embedHTML = this.sanitizer.bypassSecurityTrustHtml(html)
  }
}