0

I'm having some trouble autoplaying the video when loading the page. The video source URL is loaded dinamically so I've wrapped vg-player with a div and a ngIf so it shows only when the source URL is not empty. If I add the autoplay="true" to the video tag when I recompile the first time it works but on every reload of the page after it doesn't work anymore. The video loads correctly but I have to press the play button manually.

I've also tried to implement APIs using the onPlayerReady event but then the subscribe is not fired.

ngx-videogular version: 6.0.0

enter image description here

enter image description here

enter image description here

1 Answers1

0

in html:

<vg-player (onPlayerReady)="onPlayerReady($event)">
  <video>...</video>
</vg-player>

in ts, subscribe to loadedMetadata, example:

api: VgApiService;
onPlayerReady(source: VgApiService) {
this.api = source;
this.api.getDefaultMedia().subscriptions.loadedMetadata.subscribe(this.play.bind(this))
}
play() {
this.api.play();
}