admin管理员组

文章数量:1355996

I have a website set-up, where the background is a YouTube video using Tubular.js plugin. There is a problem with chrome browsers, that auto pauses the youtube video if I load it with mute: false flag. Chrome is the only offender, as it works with opera, firefox etc. If I change the flag to mute: true the video will atuplay fine.

Chrome recently started to block atuplayed videos with sound. Is there an option to bypass this on chrome, or at least modify the tubular.js library/js call so that it will only mute (regardless of settings) on chrome user-agents?

Thanks in advance

I have a website set-up, where the background is a YouTube video using Tubular.js plugin. There is a problem with chrome browsers, that auto pauses the youtube video if I load it with mute: false flag. Chrome is the only offender, as it works with opera, firefox etc. If I change the flag to mute: true the video will atuplay fine.

Chrome recently started to block atuplayed videos with sound. Is there an option to bypass this on chrome, or at least modify the tubular.js library/js call so that it will only mute (regardless of settings) on chrome user-agents?

https://codepen.io/anon/pen/MGEZrO

Thanks in advance

Share Improve this question asked May 6, 2018 at 15:36 jackarjackar 1291 gold badge1 silver badge12 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

According to chrome logic it is impossible to autoplay video if it is NOT muted. However they allow to autoplay video if it is muted and WILL NOT stop it if user will unmute it. By this (user interaction) chrome means just a single tap OR click by the user on the website (everywhere, not video ponents only).

Just make your user to make a single click on your webpage and THEN you can mount/start video with autoplay and sound.

I have the similar situation with my react spa. And I force my user to make a single click before mounting the video. Only this way it starts to play with sound.

I also had the situation where the video MUST have started even without click and the I just addEventListener on whole page to unmute it as soon as possible

play(from = null) {
  document.addEventListener('click', () => {
  // any click will force my video to unmute
  this.player.muted = false; 
  });
  // rest code for updating state etc
}

Unfortunately, triggering click is not working (the video will stop automatically)

According to their guidelines about autoplay on chrome ;

Unfortunately, Chrome cannot provide any whitelist exceptions to the autoplay policy.

They also explain how to present the content in a less-invasive way (muted video first) and some other tips about the policy.

本文标签: javascriptBypassing chrome autopause on videos with soundStack Overflow