Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML video autoplay without muted (or how does youtube do it)?

I know that many newer browsers now disable autoplay when the video isn't muted or mute it and then play. Without user interaction it's also not possible to call play on a video. That's understandable, but I'm wondering how youtube is still able to start the videos with sound.

I checked and they do use the video tag, just not with any autoplay/muted attributes and loading some blob. It's not the user interaction opening the video, it also starts when opening a link in incognito mode.

So my conclusion, it should still be possible. But how? Or did browsers add some kind of exception for trusted video streaming sites?

Thanks in advance

like image 819
Aram Becker Avatar asked Jun 16 '18 18:06

Aram Becker


1 Answers

For the Youtube case, it is probably a pre-populated white list

https://blog.google/products/chrome/improving-autoplay-chrome/

If you don’t have browsing history, Chrome allows autoplay for over 1,000 sites where we see that the highest percentage of visitors play media with sound.


For other generic cases, you can refer to the following rules (for Chrome at least)

https://developers.google.com/web/updates/2017/09/autoplay-policy-changes

Autoplay with sound is allowed if:

User has interacted with the domain (click, tap, etc.).

On desktop, the user's Media Engagement Index threshold has been crossed, meaning the user has previously play video with sound.

On mobile, the user has added the site to his or her home screen.

like image 171
William Chong Avatar answered Sep 21 '22 02:09

William Chong