-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
fix: force autoplay in Chrome #4804
Conversation
src/js/tech/html5.js
Outdated
@@ -329,6 +333,7 @@ class Html5 extends Tech { | |||
} | |||
} | |||
|
|||
this.hasStartedPlayback_ = el.paused; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
el.paused
, is also true if it's never played.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, this should actually be !el.paused
. Also @andriybohdan tested it and found that it just autoplayed everything, probably because of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might also be too late to check anyway. The element would be moved and apparently paused at https://github.com/videojs/video.js/blob/master/src/js/player.js#L643.
What is the disadvantage to creating a new video el as we do for iphone?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recreating the element in all conditions could potentially be a breaking change.
However, it'll be something to consider if this type of workaround wouldn't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I think this place is fine because we set the autoplay
attribute a few lines above. Seems like !el.paused
seems to work here but I guess we'd want to do more tests before pulling it in.
Looks like getting the conditional right also fixed the tests :) |
Seems like doing the check here isn't good enough. Seems like there are two options:
Option 1 isn't great because we had just removed code like this. Might be ok if we check for chrome and autoplay and we aren't playing already at the end of video.js initialization. |
7e57c3d
to
9b310b8
Compare
QA-LGTM |
This reverts commit 6fe7a9a. The PR #4804, which fixes #4720, causes a regression #5005. When testing for the regression, the original issue is no longer reproducible so the fix should be backed out. If someone is still using the old version of chrome and seeing the behavior of #4720, they can continue using the versions of Video.js that contain the fixed made in #4804: 6.5.2, 6.6x, 6.7.x. Fixes #5005.
Chrome has started pausing autoplaying video elements when they are
moved in the DOM. Here we need to make sure that if the video started
autoplaying, after we move the element in the DOM we call play again.
Fixes #4720.