aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+my-account/my-account-videos/modals/live-stream-information.component.ts
blob: a5885a8e7989f1e35c8bd7d4f72c64e51eb5ad7b (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
36
37
38
39
40
import { Component, ElementRef, ViewChild } from '@angular/core'
import { LiveVideoService, Video } from '@app/shared/shared-main'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'

@Component({
  selector: 'my-live-stream-information',
  templateUrl: './live-stream-information.component.html',
  styleUrls: [ './live-stream-information.component.scss' ]
})
export class LiveStreamInformationComponent {
  @ViewChild('modal', { static: true }) modal: ElementRef

  video: Video
  rtmpUrl = ''
  streamKey = ''

  constructor (
    private modalService: NgbModal,
    private liveVideoService: LiveVideoService
  ) { }

  show (video: Video) {
    this.video = video
    this.rtmpUrl = ''
    this.streamKey = ''

    this.loadLiveInfo(video)

    this.modalService
      .open(this.modal, { centered: true })
  }

  private loadLiveInfo (video: Video) {
    this.liveVideoService.getVideoLive(video.id)
      .subscribe(live => {
        this.rtmpUrl = live.rtmpUrl
        this.streamKey = live.streamKey
      })
  }
}