From f8c00564e7e66c7c9d65ea044a4c1485df0e4c7c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 5 Nov 2020 10:56:23 +0100 Subject: Add live info in watch page --- .../shared/shared-video-live/live-video.service.ts | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 client/src/app/shared/shared-video-live/live-video.service.ts (limited to 'client/src/app/shared/shared-video-live/live-video.service.ts') diff --git a/client/src/app/shared/shared-video-live/live-video.service.ts b/client/src/app/shared/shared-video-live/live-video.service.ts new file mode 100644 index 000000000..b02442eae --- /dev/null +++ b/client/src/app/shared/shared-video-live/live-video.service.ts @@ -0,0 +1,34 @@ +import { catchError } from 'rxjs/operators' +import { HttpClient } from '@angular/common/http' +import { Injectable } from '@angular/core' +import { RestExtractor } from '@app/core' +import { LiveVideo, LiveVideoCreate, LiveVideoUpdate } from '@shared/models' +import { environment } from '../../../environments/environment' + +@Injectable() +export class LiveVideoService { + static BASE_VIDEO_LIVE_URL = environment.apiUrl + '/api/v1/videos/live/' + + constructor ( + private authHttp: HttpClient, + private restExtractor: RestExtractor + ) {} + + goLive (video: LiveVideoCreate) { + return this.authHttp + .post<{ video: { id: number, uuid: string } }>(LiveVideoService.BASE_VIDEO_LIVE_URL, video) + .pipe(catchError(err => this.restExtractor.handleError(err))) + } + + getVideoLive (videoId: number | string) { + return this.authHttp + .get(LiveVideoService.BASE_VIDEO_LIVE_URL + videoId) + .pipe(catchError(err => this.restExtractor.handleError(err))) + } + + updateLive (videoId: number | string, liveUpdate: LiveVideoUpdate) { + return this.authHttp + .put(LiveVideoService.BASE_VIDEO_LIVE_URL + videoId, liveUpdate) + .pipe(catchError(err => this.restExtractor.handleError(err))) + } +} -- cgit v1.2.3