6
votes

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:

  • Go to http://www.tandem.io and create a room
  • Go to your newly created room in Chrome AND firefox (or Opera)
  • Mute the player in Opera
  • Make sure the Chrome tab does not have focus
  • Add a YouTube video to the playlist in Opera
  • The video won't play in Chrome until the tab/window is active
2
Isn't that a feature? I assume your question is "how to make it play?" Because you don't ask anything.Bas van Stein
I suppose the question is, why is autoplayed video behavior inconsistent in Chrome even when the tab has had focus once?Fauntleroy
@BasvanStein I would like to ask the question how to make it play. :)Spaceman

2 Answers

1
votes

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.