When installing this module videos won't start auto-playing in Chrome anymore. Probably a conflict between the JavaScript libraries?

The answer by Arnaud Leyder on this Stack Overflow question might clarify the issue:

http://stackoverflow.com/a/26907606/1165159

Comments

rroose created an issue. See original summary.

rroose’s picture

Issue summary: View changes
rroose’s picture

Title: Installing module disables auto-play of videos » Installing module disables auto-play of videos in Chrome
Issue summary: View changes
tanc’s picture

Hi there,

Do you have a site set up publicly where I can see this in action? It sounds like an issue with mmenu rather than this module. Looking at their issues I see this one: https://github.com/FrDH/jQuery.mmenu/issues/162

There doesn't seem to be a fix in the mmenu code, but there is a suggested workaround. For me to test and try this I'll need a basic site with an autoplay video set up. Any chance you can package a D8 site with a database so I can install locally and test? Or provide quick to follow step by step instructions on how to set up a test site with an autoplay video?

rroose’s picture

StatusFileSize
new48.02 MB

Hi Tancredi,

I've created a test site just for this issue, see:

http://dev-autoplay.pantheonsite.io/

I've included the files of the dump. If necessary (or easier) I can also add you the Pantheon team for this site.

As soon as I uploaded the mmenu library the videos stopped autoplaying so I think you assessment is correct that the fault lies within this library.

I've sent you the login details in a private message. Let me know if you need anything else!

tanc’s picture

Version: 8.x-2.0-alpha1 » 8.x-2.x-dev
Assigned: Unassigned » tanc
Status: Active » Needs review
StatusFileSize
new1.01 KB

Hi @rroose, thanks for setting that up. I was able to replicate the issue and I think I can provide a fix.

The patch adds a small bit of javascript which triggers the playing of videos on the page which have received the canplaythrough event after the DOM has been manipulated by mmenu. This means that autoplay videos which have been paused by the Chrome bug when the DOM manipulation occurs but should be playing will be triggered, and those that are still buffering while the DOM manipulation occurs should naturally autoplay when they are ready. There is also a race condition with setting the event listener but I've worked around that using the video readyState.

Can you please test and let me know whether its working for you? I've checked in Chrome, Firefox, IE11, Edge and Safari and all work as expected.

tanc’s picture

StatusFileSize
new1.03 KB

Attached is a better patch which doesn't cause js errors if there is no video on the page.

tanc’s picture

Hi @rroose, did you get a chance to test this?

toddses’s picture

Hi @tanc we are having this issue on a site. I'll test the patch and let you know shortly.

toddses’s picture

@tanc the patch did indeed fix the issue. Note that the issue affects the D7 version of the plugin as well, and that's where I tested the fix.

kumkum29’s picture

Hello,

I reopen this post because the patch don't work for my site.
I use a bootstrap theme, and I have added a wrapper for my page (to resolve a bug with bootstrap). Inside this page wrapper we have the html5 video. On Chrome the video don't launch...

Thanks for your help.

tanc’s picture

Status: Needs review » Needs work
tanc’s picture

Status: Needs work » Closed (outdated)

I'm reluctant to maintain browser fixes so I'll close this issue and hope that Chrome have fixed their bug (or maybe feature?). The patch is there so people can use it if they need.