2

With the recent changes to how Chrome autoplays videos, I'm trying to determine if there is a way to have a play promise for an autoplaying iframe, more specifically the YouTube API.

Currently, I'm using this code for HTML5 <video>'s:

var promise = $( 'video' ).get(0).play();

if (promise !== undefined) {
  promise.then(_ => {
    // Autoplay started!
  }).catch(error => {
    // Autoplay was prevented.
  });
}

But if I'm using the YouTube API, I can not get the video object. I tried the code below, but it won't work due to no object.

var promise = YTPlayer.playVideo()

Does anyone have any recommendations or know if this is even possible at the moment?

Thanks!

Blake
  • 561
  • 5
  • 14

0 Answers0