【发布时间】:2018-11-22 04:05:25
【问题描述】:
如何使用 Videogular 播放本地视频文件。我知道出于安全原因,用户必须手动选择文件。但是,我不知道如何将videogular的来源设置为所选文件。
我正在使用ng2-file-input 来获取文件参考。但是,设置此文件引用在videogular 中不起作用。
app.component.ts
export class AppComponent {
api: VgAPI;
mediaSrc: string;
mediaType: string;
public onAction($event) {
const media = $event.currentFiles[0];
this.mediaSrc = URL.createObjectURL(media);
this.mediaType = media.type;
this.api.play();
}
public onPlayerReady(api: VgAPI) {
this.api = api;
}
}
app.component.html
<ng2-file-input (onAction)="onAction($event)"></ng2-file-input>
<vg-player (onPlayerReady)="onPlayerReady($event)">
<video [vgMedia]="media" #media id="singleVideo" preload="auto" controls>
<source [src]="mediaSrc" [type]="mediaType">
</video>
</vg-player>
【问题讨论】:
标签: angular video videogular