Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML5 video autoplay in chrome #687

Closed
istvanvasil opened this issue Oct 19, 2018 · 9 comments
Closed

HTML5 video autoplay in chrome #687

istvanvasil opened this issue Oct 19, 2018 · 9 comments

Comments

@istvanvasil
Copy link

Hi!
I am trying to improve a project I have recently finished. Facing some issues when it comes to html5 video autoplay in Chrome. I think it's connected to how Choo works but might be mistaken. I appreciate any help. See behaviour below.

Expected behavior

Starts autoplay of video when visiting address in chrome.

Actual behavior

Shows first frame. Plays only if navigating away within the app and navigating back. Not on direct landing via browsers address bar.

Steps to reproduce behavior

Visit https://josefinelaul.com/404 in Chrome
Video doesn't start
Navigate away using the arrow in the corner.
Then navigate back using the browsers navigation buttons.
Now it plays.

I use the code as follows

<video id="MyVideo" autoplay="autoplay" loop="loop" muted="muted" playsinline="playsinline" src="/content/3-404/leaves.mp4" class="w100"></video>

@goto-bus-stop
Copy link
Member

goto-bus-stop commented Oct 19, 2018

Chrome really dislikes autoplaying video without interaction. That's probably why it starts working after navigating away and back; you've already interacted with the page, so Chrome allows it to autoplay. (This way you won't get autoplaying videos in popups or tabs you don't actually use, so it kinda makes sense)

My understanding of Chrome's policy though is that muted videos should autoplay fine, so there's probably still something else going on here too!

For reference: https://www.chromium.org/audio-video/autoplay

@istvanvasil
Copy link
Author

istvanvasil commented Oct 19, 2018

Exactly @goto-bus-stop

I've searched a lot on this and seems like people in Angular had some similar issue as well. I've seen the same video tag execute as intended in Vue. So it seems that it is affected by the framework.

I use browserify together with yo-yoify, es2040 and tinyify to bundle up my project.

@istvanvasil
Copy link
Author

@tornqvist did you encounter anything like this when working on quantifiedplanet.org header video?

@tornqvist
Copy link
Member

Like @goto-bus-stop says autoplaying video is a real hassle. In the case of quantified planet we're actually attaching listeners for the canplay event and trigger play programmatically and switching between a short video and a longer one once loaded. You can check out the source code for the video player is here: https://github.com/codeandconspire/quantifiedplanet.org/blob/master/components/story/video.js

@AntonTrollback
Copy link

Minor note that might save you debugging time: videos never autoplay on iOS with battery saving mode turned on.

@bcomnes
Copy link
Collaborator

bcomnes commented Oct 19, 2018

Sounds like the chrome changes may get reverted: https://games.slashdot.org/story/18/10/16/169242/chrome-70-wont-ship-with-a-patch-for-autoplay-blocking-web-audio-api-which-broke-web-apps-and-games-earlier-this-year

Cool to close this? Its not really a choo specific issue.

@bcomnes
Copy link
Collaborator

bcomnes commented Oct 19, 2018

IME video reuiqres user input at this point on chrome.

@istvanvasil
Copy link
Author

Thank you all for the information and help.

@caiogondim
Copy link

Hi there. I have to deal with this almost every day on my work.
It's a quite hairy topic, but a TL;DR is:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants