aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-custom-markup/peertube-custom-tags/embed-markup.component.ts
blob: 53b70cc4759aeaf714ada1dcf01cdfa7a51120b0 (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
import { buildVideoOrPlaylistEmbed } from 'src/assets/player/utils'
import { environment } from 'src/environments/environment'
import { Component, ElementRef, Input, OnInit } from '@angular/core'
import { buildPlaylistEmbedLink, buildVideoEmbedLink } from '@shared/core-utils'
import { CustomMarkupComponent } from './shared'

@Component({
  selector: 'my-embed-markup',
  template: ''
})
export class EmbedMarkupComponent implements CustomMarkupComponent, OnInit {
  @Input() uuid: string
  @Input() type: 'video' | 'playlist' = 'video'

  loaded: undefined

  constructor (private el: ElementRef) { }

  ngOnInit () {
    const link = this.type === 'video'
      ? buildVideoEmbedLink({ uuid: this.uuid }, environment.originServerUrl)
      : buildPlaylistEmbedLink({ uuid: this.uuid }, environment.originServerUrl)

    this.el.nativeElement.innerHTML = buildVideoOrPlaylistEmbed(link, this.uuid)
  }
}