When I attempt to create a YouTube iframe player with autoplay
in a Google Chrome tab that doesn't have focus the video won't start until the tab gains focus. Even manually calling playVideo
won't get the video to play. At first I thought this was part of the new feature that prevents YouTube videos from playing in newly opened tabs, but this only seems to effect Google Chrome.
You can replicate the issue in the wild by doing the following:
The IFrame player API lets you embed a YouTube video player on your website and control the player using JavaScript. Using the API's JavaScript functions, you can queue videos for playback; play, pause, or stop those videos; adjust the player volume; or retrieve information about the video being played.
I believe this is a Chrome browser feature in that it prevents JS from firing if the tab is blurred.
You can recreate this by visiting youtube.com and opening a number of videos in new tabs but not visit those tabs, the blurred tabs will not begin autoplaying the video until it has been focused at least once.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With