aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-custom-markup/embed-markup.component.ts
blob: a854d89f6fb4803898955b35f23c1d96174e298a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { buildPlaylistLink, buildVideoLink, buildVideoOrPlaylistEmbed } from 'src/assets/player/utils'
import { environment } from 'src/environments/environment'
import { Component, ElementRef, Input, OnInit } from '@angular/core'

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

  constructor (private el: ElementRef) { }

  ngOnInit () {
    const link = this.type === 'video'
      ? buildVideoLink({ baseUrl: `${environment.originServerUrl}/videos/embed/${this.uuid}` })
      : buildPlaylistLink({ baseUrl: `${environment.originServerUrl}/video-playlists/embed/${this.uuid}` })

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