]>
Commit | Line | Data |
---|---|---|
c6c0fa6c C |
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' | |
39e68a32 | 5 | import { LiveVideo, LiveVideoCreate, LiveVideoSession, LiveVideoUpdate, ResultList, VideoCreateResult } from '@shared/models' |
f8c00564 | 6 | import { environment } from '../../../environments/environment' |
f40712ab | 7 | import { VideoService } from '../shared-main' |
c6c0fa6c C |
8 | |
9 | @Injectable() | |
a5cf76af | 10 | export class LiveVideoService { |
c6c0fa6c C |
11 | static BASE_VIDEO_LIVE_URL = environment.apiUrl + '/api/v1/videos/live/' |
12 | ||
13 | constructor ( | |
14 | private authHttp: HttpClient, | |
15 | private restExtractor: RestExtractor | |
16 | ) {} | |
17 | ||
b5b68755 | 18 | goLive (video: LiveVideoCreate) { |
c6c0fa6c | 19 | return this.authHttp |
2e80d256 | 20 | .post<{ video: VideoCreateResult }>(LiveVideoService.BASE_VIDEO_LIVE_URL, video) |
c6c0fa6c C |
21 | .pipe(catchError(err => this.restExtractor.handleError(err))) |
22 | } | |
23 | ||
24 | getVideoLive (videoId: number | string) { | |
25 | return this.authHttp | |
a5cf76af | 26 | .get<LiveVideo>(LiveVideoService.BASE_VIDEO_LIVE_URL + videoId) |
c6c0fa6c C |
27 | .pipe(catchError(err => this.restExtractor.handleError(err))) |
28 | } | |
b5b68755 | 29 | |
39e68a32 C |
30 | listSessions (videoId: number | string) { |
31 | return this.authHttp | |
32 | .get<ResultList<LiveVideoSession>>(LiveVideoService.BASE_VIDEO_LIVE_URL + videoId + '/sessions') | |
33 | .pipe(catchError(err => this.restExtractor.handleError(err))) | |
34 | } | |
35 | ||
f40712ab C |
36 | findLiveSessionFromVOD (videoId: number | string) { |
37 | return this.authHttp | |
38 | .get<LiveVideoSession>(VideoService.BASE_VIDEO_URL + '/' + videoId + '/live-session') | |
39 | .pipe(catchError(err => this.restExtractor.handleError(err))) | |
40 | } | |
41 | ||
b5b68755 C |
42 | updateLive (videoId: number | string, liveUpdate: LiveVideoUpdate) { |
43 | return this.authHttp | |
44 | .put(LiveVideoService.BASE_VIDEO_LIVE_URL + videoId, liveUpdate) | |
45 | .pipe(catchError(err => this.restExtractor.handleError(err))) | |
46 | } | |
c6c0fa6c | 47 | } |