From c6c0fa6cd8fe8f752463d8982c3dbcd448739c4e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 17 Sep 2020 09:20:52 +0200 Subject: Live streaming implementation first step --- .../+videos/+video-edit/shared/video-edit-utils.ts | 35 ++++++++++++++++++++++ .../+video-edit/shared/video-edit.component.html | 23 ++++++++++++++ .../+video-edit/shared/video-edit.component.ts | 16 +++++++--- .../+videos/+video-edit/shared/video-edit.type.ts | 1 + 4 files changed, 71 insertions(+), 4 deletions(-) create mode 100644 client/src/app/+videos/+video-edit/shared/video-edit-utils.ts create mode 100644 client/src/app/+videos/+video-edit/shared/video-edit.type.ts (limited to 'client/src/app/+videos/+video-edit/shared') diff --git a/client/src/app/+videos/+video-edit/shared/video-edit-utils.ts b/client/src/app/+videos/+video-edit/shared/video-edit-utils.ts new file mode 100644 index 000000000..3a7dbed36 --- /dev/null +++ b/client/src/app/+videos/+video-edit/shared/video-edit-utils.ts @@ -0,0 +1,35 @@ +import { FormGroup } from '@angular/forms' +import { VideoEdit } from '@app/shared/shared-main' + +function hydrateFormFromVideo (formGroup: FormGroup, video: VideoEdit, thumbnailFiles: boolean) { + formGroup.patchValue(video.toFormPatch()) + + if (thumbnailFiles === false) return + + const objects = [ + { + url: 'thumbnailUrl', + name: 'thumbnailfile' + }, + { + url: 'previewUrl', + name: 'previewfile' + } + ] + + for (const obj of objects) { + if (!video[obj.url]) continue + + fetch(video[obj.url]) + .then(response => response.blob()) + .then(data => { + formGroup.patchValue({ + [ obj.name ]: data + }) + }) + } +} + +export { + hydrateFormFromVideo +} diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.html b/client/src/app/+videos/+video-edit/shared/video-edit.component.html index 842997b20..c444dd8d3 100644 --- a/client/src/app/+videos/+video-edit/shared/video-edit.component.html +++ b/client/src/app/+videos/+video-edit/shared/video-edit.component.html @@ -195,6 +195,29 @@ + + Live settings + + +
+
+ +
+ + +
+ +
+ + +
+
+
+
+ +
+ + Advanced settings diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts index f04111e69..bee65184b 100644 --- a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts +++ b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts @@ -20,10 +20,11 @@ import { import { FormReactiveValidationMessages, FormValidatorService, SelectChannelItem } from '@app/shared/shared-forms' import { InstanceService } from '@app/shared/shared-instance' import { VideoCaptionEdit, VideoEdit, VideoService } from '@app/shared/shared-main' -import { ServerConfig, VideoConstant, VideoPrivacy } from '@shared/models' +import { ServerConfig, VideoConstant, VideoLive, VideoPrivacy } from '@shared/models' import { RegisterClientFormFieldOptions, RegisterClientVideoFieldOptions } from '@shared/models/plugins/register-client-form-field.model' import { I18nPrimengCalendarService } from './i18n-primeng-calendar.service' import { VideoCaptionAddModalComponent } from './video-caption-add-modal.component' +import { VideoEditType } from './video-edit.type' type VideoLanguages = VideoConstant & { group?: string } @@ -40,7 +41,8 @@ export class VideoEditComponent implements OnInit, OnDestroy { @Input() schedulePublicationPossible = true @Input() videoCaptions: (VideoCaptionEdit & { captionPath?: string })[] = [] @Input() waitTranscodingEnabled = true - @Input() type: 'import-url' | 'import-torrent' | 'upload' | 'update' + @Input() type: VideoEditType + @Input() videoLive: VideoLive @ViewChild('videoCaptionAddModal', { static: true }) videoCaptionAddModal: VideoCaptionAddModalComponent @@ -124,7 +126,8 @@ export class VideoEditComponent implements OnInit, OnDestroy { previewfile: null, support: VIDEO_SUPPORT_VALIDATOR, schedulePublicationAt: VIDEO_SCHEDULE_PUBLICATION_AT_VALIDATOR, - originallyPublishedAt: VIDEO_ORIGINALLY_PUBLISHED_AT_VALIDATOR + originallyPublishedAt: VIDEO_ORIGINALLY_PUBLISHED_AT_VALIDATOR, + liveStreamKey: null } this.formValidatorService.updateForm( @@ -320,7 +323,12 @@ export class VideoEditComponent implements OnInit, OnDestroy { const currentSupport = this.form.value[ 'support' ] // First time we set the channel? - if (isNaN(oldChannelId) && !currentSupport) return this.updateSupportField(newChannel.support) + if (isNaN(oldChannelId)) { + // Fill support if it's empty + if (!currentSupport) this.updateSupportField(newChannel.support) + + return + } const oldChannel = this.userVideoChannels.find(c => c.id === oldChannelId) if (!newChannel || !oldChannel) { diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.type.ts b/client/src/app/+videos/+video-edit/shared/video-edit.type.ts new file mode 100644 index 000000000..fdbe9505c --- /dev/null +++ b/client/src/app/+videos/+video-edit/shared/video-edit.type.ts @@ -0,0 +1 @@ +export type VideoEditType = 'update' | 'upload' | 'import-url' | 'import-torrent' | 'go-live' -- cgit v1.2.3