4

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

jackar
  • 99
  • 1
  • 1
  • 10

2 Answers2

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 components 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)

Aleksey Spirin
  • 170
  • 2
  • 8
  • 1
    Wow, this is so beautifully evil I think I will stay far away from any implementation of this and instead admire it from a safe distance. – Fabian N. Aug 07 '18 at 21:56
-1

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.

Dranna
  • 505
  • 3
  • 15
  • I understand why they introduced this, but unfortunately having auto sound is crucial to me. Is there a way to load the video muted first, then unmute it using `` or similar? – jackar May 06 '18 at 15:48
  • Not to my knowledge. But look in the page and the links under "more information". There is a policy that let you autoplay if you have a "user interaction with the domain". Maybe you can find a compromise, but I don't think you will be able to rollback their policy update. – Dranna May 06 '18 at 15:58
  • According to this blog post https://blog.google/products/chrome/improving-autoplay-chrome/ they admit that they have actually whitelist for about 1000 pages, which is imho very unfair and might by even illegal as it discriminates competition. – Luckylooke May 13 '23 at 05:48