feross/yt-player

player.play(); not playing at all.

ThaoD5 opened this issue · 3 comments

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, cover img tag over it
    , js click event on the image to fadeout the image, and get the youtube iframe 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

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.

@feross which event handler are you refering to ?