+import { forkJoin } from 'rxjs'
import { Component, EventEmitter, OnInit, Output } from '@angular/core'
import { Router } from '@angular/router'
import { AuthService, CanComponentDeactivate, Notifier, ServerService } from '@app/core'
import { scrollToTop } from '@app/helpers'
import { FormValidatorService } from '@app/shared/shared-forms'
-import { VideoCaptionService, VideoEdit, VideoService, VideoLiveService } from '@app/shared/shared-main'
+import { LiveVideoService, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main'
import { LoadingBarService } from '@ngx-loading-bar/core'
-import { VideoCreate, VideoLive, VideoPrivacy } from '@shared/models'
+import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoPrivacy } from '@shared/models'
import { VideoSend } from './video-send'
@Component({
isInUpdateForm = false
- videoLive: VideoLive
+ liveVideo: LiveVideo
videoId: number
videoUUID: string
error: string
protected serverService: ServerService,
protected videoService: VideoService,
protected videoCaptionService: VideoCaptionService,
- private videoLiveService: VideoLiveService,
+ private liveVideoService: LiveVideoService,
private router: Router
) {
super()
}
goLive () {
- const video: VideoCreate = {
+ const video: LiveVideoCreate = {
name: 'Live',
privacy: VideoPrivacy.PRIVATE,
nsfw: this.serverConfig.instance.isNSFW,
const toPatch = Object.assign({}, video, { privacy: this.firstStepPrivacyId })
this.form.patchValue(toPatch)
- this.videoLiveService.goLive(video).subscribe(
+ this.liveVideoService.goLive(video).subscribe(
res => {
this.videoId = res.video.id
this.videoUUID = res.video.uuid
video.id = this.videoId
video.uuid = this.videoUUID
+ const liveVideoUpdate: LiveVideoUpdate = {
+ saveReplay: this.form.value.saveReplay
+ }
+
// Update the video
- this.updateVideoAndCaptions(video)
- .subscribe(
- () => {
- this.notifier.success($localize`Live published.`)
+ forkJoin([
+ this.updateVideoAndCaptions(video),
- this.router.navigate([ '/videos/watch', video.uuid ])
- },
+ this.liveVideoService.updateLive(this.videoId, liveVideoUpdate)
+ ]).subscribe(
+ () => {
+ this.notifier.success($localize`Live published.`)
+
+ this.router.navigate(['/videos/watch', video.uuid])
+ },
- err => {
- this.error = err.message
- scrollToTop()
- console.error(err)
- }
- )
+ err => {
+ this.error = err.message
+ scrollToTop()
+ console.error(err)
+ }
+ )
+ }
+ getMaxLiveDuration () {
+ return this.serverConfig.live.maxDuration / 1000
}
private fetchVideoLive () {
- this.videoLiveService.getVideoLive(this.videoId)
+ this.liveVideoService.getVideoLive(this.videoId)
.subscribe(
- videoLive => {
- this.videoLive = videoLive
+ liveVideo => {
+ this.liveVideo = liveVideo
},
err => {