ngx-videogular
ngx-videogular copied to clipboard
Autoplay not working
Description
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



Expected Behavior
Expected Behavior: video autoplay when player is loaded
Actual Behavior
Actual Behavior: I have to press play manually, autoplay works only on recompile. APIs not firing
I've also tried this piece of code

The subscribe fires but this.VGapi.play();
doesn't work and neither this.VGapi.getDefaultMedia().play()
does
This is still an issue in 7.0.1, it just doesn't work and no errors to track anything down.
I have the same issue
I also have the same issue please fix this
It appears the issue lies not with Videogular, but rather with Angular itself. Here's the solution that resolved the problem for me:
<video
#media
(onGetBitrates)="bitrates = $event"
[vgMedia]="$any(media)"
[vgHls]="currentStream.source"
crossorigin
(canplay)="media.play()"
(loadedmetadata)="media.muted = true">
</video>
https://stackoverflow.com/a/53767478