1 import { catchError } from 'rxjs/operators'
2 import { HttpClient } from '@angular/common/http'
3 import { Injectable } from '@angular/core'
4 import { RestExtractor } from '@app/core'
5 import { LiveVideo, LiveVideoCreate, LiveVideoSession, LiveVideoUpdate, ResultList, VideoCreateResult } from '@shared/models'
6 import { environment } from '../../../environments/environment'
7 import { VideoService } from '../shared-main'
10 export class LiveVideoService {
11 static BASE_VIDEO_LIVE_URL = environment.apiUrl + '/api/v1/videos/live/'
14 private authHttp: HttpClient,
15 private restExtractor: RestExtractor
18 goLive (video: LiveVideoCreate) {
20 .post<{ video: VideoCreateResult }>(LiveVideoService.BASE_VIDEO_LIVE_URL, video)
21 .pipe(catchError(err => this.restExtractor.handleError(err)))
24 getVideoLive (videoId: number | string) {
26 .get<LiveVideo>(LiveVideoService.BASE_VIDEO_LIVE_URL + videoId)
27 .pipe(catchError(err => this.restExtractor.handleError(err)))
30 listSessions (videoId: number | string) {
32 .get<ResultList<LiveVideoSession>>(LiveVideoService.BASE_VIDEO_LIVE_URL + videoId + '/sessions')
33 .pipe(catchError(err => this.restExtractor.handleError(err)))
36 findLiveSessionFromVOD (videoId: number | string) {
38 .get<LiveVideoSession>(VideoService.BASE_VIDEO_URL + '/' + videoId + '/live-session')
39 .pipe(catchError(err => this.restExtractor.handleError(err)))
42 updateLive (videoId: number | string, liveUpdate: LiveVideoUpdate) {
44 .put(LiveVideoService.BASE_VIDEO_LIVE_URL + videoId, liveUpdate)
45 .pipe(catchError(err => this.restExtractor.handleError(err)))