Skip to content
This repository has been archived by the owner on Jan 12, 2019. It is now read-only.

Fix tech.play() throwing unresolved promise errors on Chrome #1338

Merged
merged 2 commits into from
Feb 27, 2018

Conversation

grobolom
Copy link
Contributor

@grobolom grobolom commented Feb 10, 2018

Description

This is an enhancement that fixes errors being thrown by videojs-contrib-hls on Chrome. While the error does not impact player functionality, it pollutes the console log, which may result in confusion or time wasted during manual/automated testing. The error is caused by the media .play() event returning a Promise in Chrome, which throws the error The play() request was interrupted by a call to pause().

The fix is mirrored from a similar fix in the video.js core repo, which simply wraps the return value of .play() in a promise if necessary.

Specific Changes proposed

This fix proposes to wrap the this.tech_.play() call in handleSourceOpen_() in the master-playlist-controller with a .then(), so that Chrome does not show a Promise-based error.

Requirements Checklist

  • Feature implemented / Bug fixed
  • If necessary, more likely in a feature request than a bug fix
  • Reviewed by Two Core Contributors

Copy link
Contributor

@gesinger gesinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, just one minor comment


// Catch/silence error when a pause interrupts a play request
// on browsers which return a promise
if (playPromise !== undefined && typeof playPromise.then === 'function') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the linter might warn to use typeof playPromise !== 'undefined'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gesinger cool! I'll update later today.


// Catch/silence error when a pause interrupts a play request
// on browsers which return a promise
if (playPromise !== undefined && typeof playPromise.then !== 'undefined') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update @grobolom ! Though in this case the typeof comparing to a function is OK (and preferred), but the playPromise !== undefined should probably be typeof playPromise !== 'undefined'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aaaah. I see. My bad, I'll fix that up!

@grobolom
Copy link
Contributor Author

@gesinger all fixed up 👍

@grobolom
Copy link
Contributor Author

@gesinger hey man, just wondering - is there an approximate timeline for when PRs get merged in these repositories? I understand it's not a high-traffic area, but it would be cool for to try this out in our code (and avoid some errors). No rush though, just asking :)

@gesinger
Copy link
Contributor

Hey @grobolom , sorry about the delay. No set timeline, we were just focused on some other issues. That said, this is all set to go except we do a quick round of manual testing before merging it in. We'll try to get around to it today if we can.

@gesinger gesinger merged commit 80e9b0b into videojs:master Feb 27, 2018
@grobolom
Copy link
Contributor Author

@gesinger no sweat - thanks for adding this in! We really appreciate it :)

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

Successfully merging this pull request may close these issues.

3 participants