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

Autoplay in Chrome stopped working. #1240

Closed
cdeutsch opened this issue May 27, 2014 · 14 comments
Closed

Autoplay in Chrome stopped working. #1240

cdeutsch opened this issue May 27, 2014 · 14 comments

Comments

@cdeutsch
Copy link

I have an app that's over a year old and I can't get Chrome to autoplay anymore using video.js

Fiddle:
http://jsfiddle.net/cdeutsch/cjyB3/

I'm guessing something in Chrome changed.

I just confirmed that fiddle works in Chrome 34.0.1847.116 on windows (which amazingly I had open and not updated)

Does not work in 35.0.1916.114 on OSX

@emptyother
Copy link

Me and our clients got a maybe related problem today. Chrome 35 refuses to play the video at all, but only if the player is embedded in an iframe. The player controls work fine, but refuses to start the playback.
I placed a breakpoint at some .play() lines within video.js, and found nothing immediatly, but after stepping trough the code the video played as normal.
When i removed the breakpoints the video once again refused to play. Even when i right-clicked the video and choose "Play" manually it didnt react.
I am using Chrome Version 35.0.1916.114 m on Windows 8.

This is the exact code i place my breakpoint in (probably old video.js code, it havent been updated for a while):

vjs.Player.prototype.techCall = function (method, arg) {
    // If it's not ready yet, call method when it is
    if (this.tech && !this.tech.isReady_) {    // < If i place breakpoint here, and then continue script execution, the video plays fine
                                               // even within an iframe.
                                               //The check never returns true, it always proceed to the else block.
        this.tech.ready(function () {
            this[method](arg);
        });

        // Otherwise call method now
    } else {
        try {
            this.tech[method](arg);
        } catch (e) {
            vjs.log(e);
            throw e;
        }
    }
};

Edit: Confirm that it works as soon as i turn off autoplay. And i can confirm that it also works after updating videojs to a more recent version (April 8 stable release, if you want to know). Still, curious what Chrome changed from version 34 to 35.

@mmcc
Copy link
Member

mmcc commented May 28, 2014

So it looks it's working, but only if you set preload="auto" or remove it altogether if you want to use autoplay. However, once you make that change, #1237 comes into play and we see the big play button and no other controls.

AFAIK, preload should be ignored if autoplay is present, but I'm not sure if that's really in the spec of just something most browsers have done. Whatever the case is, it's clear Chrome broke this behavior in a recent version. I'll leave this issue open for now for tracking.

@johnraz
Copy link

johnraz commented May 29, 2014

I can confirm I experienced the very same thing, @mmcc's workaround works perfectly fine for now.

jharwig added a commit to lumifyio/lumify that referenced this issue May 29, 2014
Updated to more recent (but not latest) videojs, and switched configuration to work around autoload on chrome breaking.

videojs/video.js#1240
@mmcc
Copy link
Member

mmcc commented Jun 13, 2014

It looks like this is fixed in Chrome Canary (37.0.2048.2 canary), so hopefully that makes it back into the main channel. I'm going to close this one in the meantime.

@mmcc mmcc closed this as completed Jun 13, 2014
@kwolniak
Copy link

kwolniak commented Apr 6, 2016

I have Chrome 49 OSX, and autoplay don't work in Chrome for me, but it works in Firefox.
What can I do?

@ashkarpetin
Copy link

Same problem, autoplay doesn't work on Chrome 49 Windows 8.1.

@kjkta
Copy link

kjkta commented Apr 11, 2016

I'm having the same problem with the latest versions of vjs and chrome.

Having to resort to this at the moment:

window.onload = function() {
  document.querySelector('#hero-vid video').play()
}

@ChristianGiupponi
Copy link

Same problem for me

@ngocketit
Copy link

Same problem here but it was with mobile Chrome:
Mozilla/5.0 (Linux; Android 5.0.2; AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.76 Mobile Safari/537.36

Removing preload doesn't work for me.

@mikhoul
Copy link

mikhoul commented Mar 1, 2017

Same here...

@UralZima
Copy link

UralZima commented Mar 2, 2017

+1, even if I add player.play() right after creating videojs object, it doesn't work in latest chrome, only firefox.
Videojs 5.17.0

@UralZima
Copy link

UralZima commented Mar 2, 2017

Only this works for me:
setTimeout(function() { player.play(); }, 1000);

@acevski48
Copy link

acevski48 commented Nov 7, 2017

you should try using video on local server insted of external link. Auto play workd for me from local server.

@sergibondarenko
Copy link

sergibondarenko commented Feb 11, 2018

On Android, you can autoplay if you put muted option

<video autoplay muted>
  <source src="video.webm" type="video/webm" />
  <source src="video.mp4" type="video/mp4" />
</video>

https://developers.google.com/web/updates/2016/07/autoplay

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests