HTML5 Video Autoplay in Chrome for Digital Signage - html

https://developers.google.com/web/updates/2017/09/autoplay-policy-changes
A while back, Chrome changed their autoplay policy so that you can't autoplay a video unless it is muted, or the user has interacted with the web page.
I use HTML5 video as part of a digital signage application, but it's common that the page is never clicked - for example when launched automatically in Kiosk mode.
If I mute the video it can autoplay, then if I bind to the play event and try and unmute it causes the video to stop playing (I guess they thought of that). I've had no other luck with similar trickery.
I understand the reasoning behind this behavior and on a website it makes sense - but mine is not a website, it's an application.
Is there a way around this? For example, if I moved to being a Chrome Application/Extension would the policy no longer be enforced? I'm somewhat stumped and would appreciate any insight.
(Asking people to go to chrome://flags/#autoplay-policy is not really an option)

If you are able to control the launch of Chrome, then you should be able to launch chrome from the command line, or via a script, with a flag to ask it to ignore the requirement for a gesture - e.g.:
$ chrome --autoplay-policy=no-user-gesture-required
This flag changed recently which may cause some confusion or be relevant if using older versions - see this discussion for some background: https://groups.google.com/a/chromium.org/forum/#!topic/headless-dev/zxPyN5f8MAQ

Related

How video ads workarounds Chrome autoplay policy when autoplaying video with sound?

I've tried to find a workaround to autoplay video with sound on and found a couple, but none of them are works for me. Also I've found a tons of replies that this is not possible to autoplay video with sound on, but in the same time I saw a lot of video ads that start playing automatically with sound. So seems like there is a way to make it happen at least for advertisers. I heard about whitelist for websites which are allowed to autoplay with sound such as youtube, but I guess this is not the case for ads. So, does anybody know how could it be implemented that way?
this is the real reason
https://blog.google/products/chrome/improving-autoplay-chrome/
Chrome does this by learning your preferences. 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. As you browse the web, that list changes as Chrome learns and enables autoplay on sites where you play media with sound during most of your visits, and disables it on sites where you don’t. This way, Chrome gives you a personalized, predictable browsing experience.
As you teach Chrome, you may find that you need to click “play” every now and then, but overall the new policy blocks about half of unwanted autoplays, so you will have fewer surprises and less unwanted noise when you first arrive at a website. The policy is enabled in the latest version of Chrome—update today and try it out.

HLS / Media Source Extensions <video> with muted & autoplay freezes on first frame on mobiles

I attempted to add a Hero background video to our website. It's being served from mux.com.
I use it with HLS, but for Chrome it uses Media Source Extensions from what I gather.
I know that for HTML5 video to auto play, it has to be muted also, and I have both parameters over there.
Apparently, on Android Chrome I get behaviour where it freezes on the first frame (black), but doesn't continue and I cannot trace why.
In case of freezing, it still does load the video, just that it's not getting autoplayed.
I am out of clues.
Isolation sandbox:
https://codesandbox.io/s/32yky6x7mq
https://32yky6x7mq.codesandbox.io/
In my attempts, I have reduced this down to simple HTML app with Hls.js library and basic <video> tag where it breaks on mobiles.
How do I get the video to autoplay on mobiles?
P.S. To see exactly what I have tried, please see edit history, as I have been trying lots of things.
On my device specifically, Android Chrome, it's caused by Data Saver.
Disabling Data Saver, the video autoplays.
It's paradoxical, because with Data Saver I expect for the video to not be loaded at all, but it's getting loaded and the autoplay gets interrupted instead - resulting in more waste.
Possibly, there are other settings out there in the wild that prevent autoplay, for instance, couldn't find the exact reasons why iOS is not working. There are hints about playsinline attribute, which I have not tested yet. (Will update when I do)
Worth noting, is Feature-Policy header too: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Feature-Policy
It didn't help me in my scenario, but it can probably be related with autoplay in other scenarios.

Playing playlist of videos in background on Chrome

Due to a fairly recent update, Chrome no longer will autoplay media content such as video if it tries to start in a tab or window which does not have focus.
There are a few sites, including my own - which rely on switching then playing videos in the background as a music player. This has been broken by Chrome, with their idea being that it prevents annoying videos from playing.
I'm reluctant to even consider building a chrome extension to circumvent this (if that would even work), but would like to hear how if possible. Is there any way to get around this annoying issue?
edit: according to this reddit post it may not be Chrome, but YouTube's chrome specific implementation...
edit2: this Chrome issue states that “Once a tab / RenderFrame has ever played media before, it’s allowed to continue to autoplay/autoload indefinitely; this is to support playlist type applications.” - Perhaps if somehow a 'RenderFrame' contains all future media which is also loaded by AJAX this will work... whatever a render frame is (Since as noted in the comments, a page reload/change does not count as the user having allowed autoplay.)

How does Chrome know which tabs are playing sound?

How does chrome know which tabs are playing some sound? Alternatively, how does chrome know which tabs to put the speaker sign on?
This article may be useful:
From ghacks.net:
"Google Chrome uses an internal version of Adobe Flash which Google can use to determine when Flash is being used for audio playback.
Mozilla does not have that luxury. While it is working on a patch to display indicators when HTML5 is being used for audio playback, it cannot do anything about plug-in contents on its own."
Assuming that's correct, then from there it's not hard to imagine that if they know of every single instance of flash being used for audio playback, that they probably have an associated property indicating which tab it is on.

How to allow system sleep on non-fullscreen html5 video?

We created a little chat client in our office that runs in the browser. It handles people posting pictures and gifs and embeds them. Recently we added support for imgur and gfycat's html 5 video (it auto converts gifs to mp4/webm). An unintented side effect of this is now anyone using chrome or firefox will find that their monitor will never turn off.
You can see in powercfg the culprit is these videos:
C:\WINDOWS\system32>powercfg /requests
DISPLAY:
[PROCESS] \Device\HarddiskVolume2\Program Files (x86)\Google\Chrome\Application\chrome.exe
Playing video
[PROCESS] \Device\HarddiskVolume2\Program Files (x86)\Mozilla Firefox\firefox.exe
If you pause the videos, the entries in powercfg disappear. Switching to another tab, minimizing chrome, even locking the screen don't allow the system to turn the monitor off. Internet Explorer seems to be the only browser that behaves like you'd expect and only prevents sleep when a video is fullscreen.
Is there some way to mark a video tag as 'unimportant' and basically tell the browser that it's OK to let the computer sleep while this video is playing?
It seems there is a bug in Google Chrome 38 (current release as of this writing) that causes the screen saver to be suppressed when playing HTML5 video. Normally, screensaver suppression should only occur when the video is playing in full-screen mode.
This issue appears to be resolved in the beta release of Google Chrome version 39 as it looks like a temporary fix was made.