How can I play a local video file using Videogular. I know that for security reasons, the user has to manually select the file. However, I don't know how to set the source of videogular
to the selected file.
I am using ng2-file-input
to get the file reference. However, setting this file reference does not work in 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>