YouTube iframe player will not play if tab / window has no focus

When I try to create a YouTube iframe player using autoplaythe Google Chrome tab in which there is no focus, the video does not start until the tab starts focusing. Even a manual call playVideowill not play the video. At first I thought it was part of a new feature that prevents YouTube videos from playing on recently opened tabs, but that only affects Google Chrome.

You can reproduce the problem 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).
  • Disable player in Opera
  • Make sure the Chrome tab is out of focus.
  • Add YouTube video to playlist in Opera
  • Video will not play in Chrome as long as the tab / window is active
+4
source share
2 answers

I believe this is a feature of the Chrome browser, as it prevents JS from starting if the tab is blurry.

You can recreate this by visiting youtube.com and opening several videos in new tabs, but without visiting these tabs, blurry tabs will not start auto-playing the video until it is focused at least once.

+1
source

You can disable this in chrome: // flags

In Chrome - chrome: // flags / # disable-gesture-requirement-for-media-playback

-1

Source: https://habr.com/ru/post/1614770/


All Articles