mirror of https://github.com/Squidex/squidex.git
17 changed files with 164 additions and 6 deletions
@ -0,0 +1 @@ |
|||||
|
<video class="video-js vjs-big-play-centered hidden" controls muted playsinline preload="none" #video></video> |
||||
@ -0,0 +1,13 @@ |
|||||
|
:host ::ng-deep { |
||||
|
.video-js { |
||||
|
&.vjs-fluid { |
||||
|
height: 100%; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
$color-video: #000; |
||||
|
|
||||
|
:host { |
||||
|
background: $color-video; |
||||
|
} |
||||
@ -0,0 +1,65 @@ |
|||||
|
/* |
||||
|
* Squidex Headless CMS |
||||
|
* |
||||
|
* @license |
||||
|
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. |
||||
|
*/ |
||||
|
|
||||
|
import { AfterViewInit, ChangeDetectionStrategy, Component, ElementRef, Input, OnChanges, OnDestroy, Renderer2, ViewChild } from '@angular/core'; |
||||
|
import { ResourceLoaderService } from '@app/framework/internal'; |
||||
|
|
||||
|
declare var videojs: any; |
||||
|
|
||||
|
@Component({ |
||||
|
selector: 'sqx-video-player', |
||||
|
styleUrls: ['./video-player.component.scss'], |
||||
|
templateUrl: './video-player.component.html', |
||||
|
changeDetection: ChangeDetectionStrategy.OnPush |
||||
|
}) |
||||
|
export class VideoPlayerComponent implements AfterViewInit, OnDestroy, OnChanges { |
||||
|
private player: any; |
||||
|
|
||||
|
@Input() |
||||
|
public source: string; |
||||
|
|
||||
|
@Input() |
||||
|
public mimeType: string; |
||||
|
|
||||
|
@ViewChild('video', { static: false }) |
||||
|
public video: ElementRef<HTMLVideoElement>; |
||||
|
|
||||
|
constructor( |
||||
|
private readonly resourceLoader: ResourceLoaderService, |
||||
|
private readonly renderer: Renderer2 |
||||
|
) { |
||||
|
} |
||||
|
|
||||
|
public ngOnDestroy() { |
||||
|
this.player?.dispose(); |
||||
|
} |
||||
|
|
||||
|
public ngOnChanges() { |
||||
|
if (this.player) { |
||||
|
if (this.source) { |
||||
|
this.player.src({ type: this.mimeType, src: this.source }); |
||||
|
} else { |
||||
|
this.player.src(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public ngAfterViewInit(): void { |
||||
|
Promise.all([ |
||||
|
this.resourceLoader.loadScript('https://vjs.zencdn.net/7.10.2/video.min.js'), |
||||
|
this.resourceLoader.loadStyle('https://vjs.zencdn.net/7.10.2/video-js.css') |
||||
|
]).then(() => { |
||||
|
this.player = videojs(this.video.nativeElement, { |
||||
|
fluid: true |
||||
|
}); |
||||
|
|
||||
|
this.renderer.removeClass(this.video.nativeElement, 'hidden'); |
||||
|
|
||||
|
this.ngOnChanges(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue