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, LiveVideoUpdate, VideoCreateResult } from '@shared/models'
6 import { environment } from '../../../environments/environment'
9 export class LiveVideoService {
10 static BASE_VIDEO_LIVE_URL = environment.apiUrl + '/api/v1/videos/live/'
13 private authHttp: HttpClient,
14 private restExtractor: RestExtractor
17 goLive (video: LiveVideoCreate) {
19 .post<{ video: VideoCreateResult }>(LiveVideoService.BASE_VIDEO_LIVE_URL, video)
20 .pipe(catchError(err => this.restExtractor.handleError(err)))
23 getVideoLive (videoId: number | string) {
25 .get<LiveVideo>(LiveVideoService.BASE_VIDEO_LIVE_URL + videoId)
26 .pipe(catchError(err => this.restExtractor.handleError(err)))
29 updateLive (videoId: number | string, liveUpdate: LiveVideoUpdate) {
31 .put(LiveVideoService.BASE_VIDEO_LIVE_URL + videoId, liveUpdate)
32 .pipe(catchError(err => this.restExtractor.handleError(err)))