diff --git a/client/src/app/+videos/+video-edit/video-update.component.ts b/client/src/app/+videos/+video-edit/video-update.component.ts
index 20438a2d3..c0f46acd2 100644
--- a/client/src/app/+videos/+video-edit/video-update.component.ts
+++ b/client/src/app/+videos/+video-edit/video-update.component.ts
@@ -5,7 +5,8 @@ import { Notifier } from '@app/core'
import { FormReactive, FormValidatorService, SelectChannelItem } from '@app/shared/shared-forms'
import { VideoCaptionEdit, VideoCaptionService, VideoDetails, VideoEdit, VideoService } from '@app/shared/shared-main'
import { LoadingBarService } from '@ngx-loading-bar/core'
-import { VideoPrivacy } from '@shared/models'
+import { VideoPrivacy, VideoLive } from '@shared/models'
+import { hydrateFormFromVideo } from './shared/video-edit-utils'
@Component({
selector: 'my-videos-update',
@@ -14,11 +15,12 @@ import { VideoPrivacy } from '@shared/models'
})
export class VideoUpdateComponent extends FormReactive implements OnInit {
video: VideoEdit
+ userVideoChannels: SelectChannelItem[] = []
+ videoCaptions: VideoCaptionEdit[] = []
+ videoLive: VideoLive
isUpdatingVideo = false
- userVideoChannels: SelectChannelItem[] = []
schedulePublicationPossible = false
- videoCaptions: VideoCaptionEdit[] = []
waitTranscodingEnabled = true
private updateDone = false
@@ -40,10 +42,11 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
this.route.data
.pipe(map(data => data.videoData))
- .subscribe(({ video, videoChannels, videoCaptions }) => {
+ .subscribe(({ video, videoChannels, videoCaptions, videoLive }) => {
this.video = new VideoEdit(video)
this.userVideoChannels = videoChannels
this.videoCaptions = videoCaptions
+ this.videoLive = videoLive
this.schedulePublicationPossible = this.video.privacy === VideoPrivacy.PRIVATE
@@ -53,7 +56,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
}
// FIXME: Angular does not detect the change inside this subscription, so use the patched setTimeout
- setTimeout(() => this.hydrateFormFromVideo())
+ setTimeout(() => hydrateFormFromVideo(this.form, this.video, true))
},
err => {
@@ -133,29 +136,4 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
pluginData: this.video.pluginData
})
}
-
- private hydrateFormFromVideo () {
- this.form.patchValue(this.video.toFormPatch())
-
- const objects = [
- {
- url: 'thumbnailUrl',
- name: 'thumbnailfile'
- },
- {
- url: 'previewUrl',
- name: 'previewfile'
- }
- ]
-
- for (const obj of objects) {
- fetch(this.video[obj.url])
- .then(response => response.blob())
- .then(data => {
- this.form.patchValue({
- [ obj.name ]: data
- })
- })
- }
- }
}
diff --git a/client/src/app/+videos/+video-edit/video-update.resolver.ts b/client/src/app/+videos/+video-edit/video-update.resolver.ts
index a391913d8..3a82324c3 100644
--- a/client/src/app/+videos/+video-edit/video-update.resolver.ts
+++ b/client/src/app/+videos/+video-edit/video-update.resolver.ts
@@ -1,13 +1,14 @@
-import { forkJoin } from 'rxjs'
+import { forkJoin, of } from 'rxjs'
import { map, switchMap } from 'rxjs/operators'
import { Injectable } from '@angular/core'
import { ActivatedRouteSnapshot, Resolve } from '@angular/router'
-import { VideoCaptionService, VideoChannelService, VideoService } from '@app/shared/shared-main'
+import { VideoCaptionService, VideoChannelService, VideoDetails, VideoLiveService, VideoService } from '@app/shared/shared-main'
@Injectable()
export class VideoUpdateResolver implements Resolve
{
constructor (
private videoService: VideoService,
+ private videoLiveService: VideoLiveService,
private videoChannelService: VideoChannelService,
private videoCaptionService: VideoCaptionService
) {
@@ -18,32 +19,38 @@ export class VideoUpdateResolver implements Resolve {
return this.videoService.getVideo({ videoId: uuid })
.pipe(
- switchMap(video => {
- return forkJoin([
- this.videoService
- .loadCompleteDescription(video.descriptionPath)
- .pipe(map(description => Object.assign(video, { description }))),
-
- this.videoChannelService
- .listAccountVideoChannels(video.account)
- .pipe(
- map(result => result.data),
- map(videoChannels => videoChannels.map(c => ({
- id: c.id,
- label: c.displayName,
- support: c.support,
- avatarPath: c.avatar?.path
- })))
- ),
-
- this.videoCaptionService
- .listCaptions(video.id)
- .pipe(
- map(result => result.data)
- )
- ])
- }),
- map(([ video, videoChannels, videoCaptions ]) => ({ video, videoChannels, videoCaptions }))
+ switchMap(video => forkJoin(this.buildVideoObservables(video))),
+ map(([ video, videoChannels, videoCaptions, videoLive ]) => ({ video, videoChannels, videoCaptions, videoLive }))
)
}
+
+ private buildVideoObservables (video: VideoDetails) {
+ return [
+ this.videoService
+ .loadCompleteDescription(video.descriptionPath)
+ .pipe(map(description => Object.assign(video, { description }))),
+
+ this.videoChannelService
+ .listAccountVideoChannels(video.account)
+ .pipe(
+ map(result => result.data),
+ map(videoChannels => videoChannels.map(c => ({
+ id: c.id,
+ label: c.displayName,
+ support: c.support,
+ avatarPath: c.avatar?.path
+ })))
+ ),
+
+ this.videoCaptionService
+ .listCaptions(video.id)
+ .pipe(
+ map(result => result.data)
+ ),
+
+ video.isLive
+ ? this.videoLiveService.getVideoLive(video.id)
+ : of(undefined)
+ ]
+ }
}
diff --git a/client/src/app/core/plugins/plugin.service.ts b/client/src/app/core/plugins/plugin.service.ts
index 4e44a1865..b755fda2c 100644
--- a/client/src/app/core/plugins/plugin.service.ts
+++ b/client/src/app/core/plugins/plugin.service.ts
@@ -2,6 +2,7 @@ import { Observable, of, ReplaySubject } from 'rxjs'
import { catchError, first, map, shareReplay } from 'rxjs/operators'
import { HttpClient } from '@angular/common/http'
import { Inject, Injectable, LOCALE_ID, NgZone } from '@angular/core'
+import { VideoEditType } from '@app/+videos/+video-edit/shared/video-edit.type'
import { AuthService } from '@app/core/auth'
import { Notifier } from '@app/core/notification'
import { MarkdownService } from '@app/core/renderer'
@@ -192,7 +193,7 @@ export class PluginService implements ClientHook {
: PluginType.THEME
}
- getRegisteredVideoFormFields (type: 'import-url' | 'import-torrent' | 'upload' | 'update') {
+ getRegisteredVideoFormFields (type: VideoEditType) {
return this.formFields.video.filter(f => f.videoFormOptions.type === type)
}
diff --git a/client/src/app/core/server/server.service.ts b/client/src/app/core/server/server.service.ts
index 5bcf33c1b..bc76bacfc 100644
--- a/client/src/app/core/server/server.service.ts
+++ b/client/src/app/core/server/server.service.ts
@@ -74,6 +74,13 @@ export class ServerService {
enabled: true
}
},
+ live: {
+ enabled: false,
+ transcoding: {
+ enabled: false,
+ enabledResolutions: []
+ }
+ },
avatar: {
file: {
size: { max: 0 },
diff --git a/client/src/app/shared/shared-forms/input-readonly-copy.component.html b/client/src/app/shared/shared-forms/input-readonly-copy.component.html
index 9566e9741..7a75bd70b 100644
--- a/client/src/app/shared/shared-forms/input-readonly-copy.component.html
+++ b/client/src/app/shared/shared-forms/input-readonly-copy.component.html
@@ -1,5 +1,5 @@