-
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: autoplay throws 'undefined promise' error on some browsers. #5283
Conversation
If the source is not loaded, `player.play();` returns `undefined` on Firefox and Edge, which causes exception. With this fix, player will not make exception and the fallback (`player.play()` execution after loading video) will be enabled.
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.
Thanks!
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.
A lack of a promise does not mean autoplay has failed. IE would autoplay but does not return a promise.
Good catch @mister-ben. I guess we should just return if there is no promise. Then as part of #3927, we can make it handle things properly if there's no play promise. |
Lack of play promise isn't necessary an autoplay error.
I agree that changing I tried this approach and I could resolve the issue itself, but some other unrelated tests, I think, were getting failed. ... |
There's some more work required for #5227 before it can be merged. I think updating this PR to just return if a promise isn't given will fix any errors and moves us closer to where we want to be. |
So, what kind of updates are needed for this PR? // src/js/player.js#L1262
+ this.trigger({type: 'autoplay-failure', autoplay: type}); should be removed? |
Yes, just that. |
Done! |
If the source is not loaded, `player.play();` returns `undefined` on Firefox and Edge, which causes exception. With this fix, player will not make exception and the fallback (`player.play()` execution after loading video) will be enabled.
Description
Handling possible exception when calling
player.autoplay()
so that the video-playing fallback implementation should work.Specific Changes proposed
If the source is not loaded,
player.play()
returnsundefined
onFirefox and Edge.
This causes an exception when
player.autoplay()
called.With this fix, player will not make an exception and the fallback
(Retrying video-play after loading video) will be enabled.
Reproduce
Reproduced on Firefox(Mac) and Edge.
Not reproduced on Chrome(Mac) and Safari
Video is played as either muted or unmuted, without clicking the video element.
video was not played, until clicking the video element.
No related console logs were generated.
player.autoplay()
is a very nice and comfortable feature!I hope it will release as soon as possible.
Requirements Checklist