player.play(); not playing at all.
ThaoD5 opened this issue · 3 comments
ThaoD5 commented
Hello,
I am trying to use your yt-player npm module because it looked interesting, unfortunately I can't seem to get my iframe
to play the video.
This is the way my front-end works :
iframe
at the back, coverimg
tag over it
, js click event on the image to fadeout the image, and get the youtubeiframe
to play the video.
I have an HTML iframe with an src already defined on load, then :
In the JS :
this.$video = this.$root.querySelector('iframe');
this.player = new YTPlayer(this.$video);
_( with or without `.load` method, same result)_
this.player.play();
I have no error, but the video doesnt start.
Did I forget anything ?
Thanks for any help
feross commented
Without a fully reproducible example, it's hard to help.
You need to ensure that play() is called synchronously within the event handler and browsers now block autoplaying video.
cyrilchapon commented
@feross which event handler are you refering to ?
feross commented
@cyrilchapon I recommend reading: https://developers.google.com/web/updates/2017/09/autoplay-policy-changes