How to bypass Chrome disabling autoplay of video's in background tabs

五迷三道 提交于 2019-12-22 12:27:09

问题


my friends and I are making a website that acts like a radio station called Musare with playlists of YouTube videos that play after each other.

Recently Chrome introduced a new 'feature' that automatically disables autoplaying of videos in background tabs with no option to turn this off. This breaks our site because users don't want to keep going back to the site to start a song. This also broke other big sites, like YouTube playlists, Facebook chat notification sound and a lot of music sharing sites.

By now, a lot of sites have found solutions to bypass this, like dubtrack.fm, YouTube, Facebook and probably some other sites as well.

There is someone working on making an option for it at https://codereview.chromium.org/1414853003/, but that might take weeks or even months for it to be in the main Google Chrome.

If anyone knows how to bypass this, please let me know.

Thanks in advance :)

Already tried:

  • Starting another video before the current one ends - no success
  • Messing around with the Player Variables - no success
  • Other things probably - no success

Extra notes:

  • We are using the YouTube API. We use YT.Player and the youtubePlayer.loadVideoById(id)
  • SoundCloud streaming works fine with SC.Stream.
  • The source code for our project is at https://github.com/Musare/Musare

回答1:


So I have found out how to bypass it finally, after many hours of trying and researching.

If you just initialize the iframe player of YouTube by using the YT.Player constructor, you can then just use the player variable and use yourPlayerVariable.loadVideoById(id).

You have to first go to the tab for it to start, but after that it will be able to load and play video's without you having to go back to the tab. If you remove and re-add the iframe, you will have to go back for it to start again.



来源:https://stackoverflow.com/questions/33787568/how-to-bypass-chrome-disabling-autoplay-of-videos-in-background-tabs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!