[ATS-854] Add media tracks to player from webvtt rendition (#6626)

* ATS-854 Add media tracks to player from webvtt rendition

* ATS-854 Fix condition

* ATS-854 Fix lint

* ATS-854 Move logic to media player

* ATS-854 Fix angular.json

* ATS-854 Fix error
This commit is contained in:
Pablo Martinez Garcia
2021-02-08 10:49:09 +01:00
committed by GitHub
parent e0462b126a
commit 5d8d5f56f3
8 changed files with 190 additions and 4 deletions

View File

@@ -17,6 +17,8 @@
import { Component, Input, OnChanges, SimpleChanges, ViewEncapsulation, Output, EventEmitter } from '@angular/core';
import { ContentService } from '../../services/content.service';
import { Track } from '../models/viewer.model';
import { ViewUtilService } from '../services/view-util.service';
@Component({
selector: 'adf-media-player',
@@ -39,18 +41,31 @@ export class MediaPlayerComponent implements OnChanges {
@Input()
nameFile: string;
@Input()
nodeId: string;
@Input()
tracks: Track[] = [];
@Output()
error = new EventEmitter<any>();
constructor(private contentService: ContentService ) {}
constructor(private contentService: ContentService, private viewUtils: ViewUtilService) {
}
ngOnChanges(changes: SimpleChanges) {
const blobFile = changes['blobFile'];
const nodeId = changes['nodeId'];
if (blobFile && blobFile.currentValue) {
this.urlFile = this.contentService.createTrustedUrl(this.blobFile);
return;
}
if (nodeId && nodeId.currentValue) {
this.viewUtils.generateMediaTracks(this.nodeId).then((tracks) => this.tracks = tracks);
}
if (!this.urlFile && !this.blobFile) {
throw new Error('Attribute urlFile or blobFile is required');
}