]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/shared/shared-video-live/live-stream-information.component.ts
Merge branch 'release/4.2.0' into develop
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-video-live / live-stream-information.component.ts
CommitLineData
d846d99c 1import { Component, ElementRef, ViewChild } from '@angular/core'
f8c00564 2import { Video } from '@app/shared/shared-main'
d846d99c 3import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
39e68a32 4import { LiveVideo, LiveVideoError, LiveVideoSession } from '@shared/models'
f8c00564 5import { LiveVideoService } from './live-video.service'
d846d99c
C
6
7@Component({
8 selector: 'my-live-stream-information',
9 templateUrl: './live-stream-information.component.html',
10 styleUrls: [ './live-stream-information.component.scss' ]
11})
12export class LiveStreamInformationComponent {
13 @ViewChild('modal', { static: true }) modal: ElementRef
14
15 video: Video
312644ce 16 live: LiveVideo
39e68a32 17 latestLiveSessions: LiveVideoSession[] = []
d846d99c
C
18
19 constructor (
20 private modalService: NgbModal,
21 private liveVideoService: LiveVideoService
22 ) { }
23
24 show (video: Video) {
25 this.video = video
312644ce 26 this.live = undefined
d846d99c
C
27
28 this.loadLiveInfo(video)
29
30 this.modalService
31 .open(this.modal, { centered: true })
32 }
33
39e68a32
C
34 getVideoUrl (video: { shortUUID: string }) {
35 return Video.buildWatchUrl(video)
36 }
37
38 getErrorLabel (session: LiveVideoSession) {
39 if (!session.error) return undefined
40
41 const errors: { [ id in LiveVideoError ]: string } = {
42 [LiveVideoError.BAD_SOCKET_HEALTH]: $localize`Server too slow`,
43 [LiveVideoError.BLACKLISTED]: $localize`Live blacklisted`,
44 [LiveVideoError.DURATION_EXCEEDED]: $localize`Max duration exceeded`,
45 [LiveVideoError.FFMPEG_ERROR]: $localize`Server error`,
46 [LiveVideoError.QUOTA_EXCEEDED]: $localize`Quota exceeded`
47 }
48
49 return errors[session.error]
50 }
51
d846d99c
C
52 private loadLiveInfo (video: Video) {
53 this.liveVideoService.getVideoLive(video.id)
312644ce 54 .subscribe(live => this.live = live)
39e68a32
C
55
56 this.liveVideoService.listSessions(video.id)
57 .subscribe(({ data }) => this.latestLiveSessions = data.slice(0, 5))
d846d99c
C
58 }
59}