Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoplay not working #105

Open
LucaDaniele99 opened this issue Jul 22, 2022 · 5 comments
Open

Autoplay not working #105

LucaDaniele99 opened this issue Jul 22, 2022 · 5 comments

Comments

@LucaDaniele99
Copy link

LucaDaniele99 commented Jul 22, 2022

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

Schermata 2022-07-22 alle 12 24 04

Schermata 2022-07-22 alle 12 24 15

Schermata 2022-07-22 alle 12 15 45

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

@LucaDaniele99
Copy link
Author

LucaDaniele99 commented Jul 24, 2022

I've also tried this piece of code

Schermata 2022-07-24 alle 15 54 25

The subscribe fires but this.VGapi.play(); doesn't work and neither this.VGapi.getDefaultMedia().play() does

@barrct
Copy link

barrct commented Apr 17, 2023

This is still an issue in 7.0.1, it just doesn't work and no errors to track anything down.

image

image

@Bazhan4ik
Copy link

I have the same issue

@AncaStefaniaa
Copy link

I also have the same issue please fix this

@Haremun
Copy link

Haremun commented May 7, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants