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

Fixing InvalidStateError in Win10 IE11 #1230

Merged
merged 4 commits into from
Aug 15, 2017

Conversation

shahlabs
Copy link
Contributor

@shahlabs shahlabs commented Aug 10, 2017

Description

Fixing InvalidStateError logged on console in Windows 10, IE11

Specific Changes proposed

Please list the specific changes involved in this pull request.

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.

Also could use unit tests.

@@ -51,7 +51,9 @@ export default class PlaybackWatcher {
this.tech_.on('seekablechanged', fixesBadSeeksHandler);
this.tech_.on('waiting', waitingHandler);
this.tech_.on(timerCancelEvents, cancelTimerHandler);
this.monitorCurrentTime_();
if (this.tech_.hasStarted_) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If the player has not started yet, but starts later, will PlaybackWatcher end up running?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think so. I think we would have to wait for either the ready or canplay event from the tech

@@ -51,7 +51,9 @@ export default class PlaybackWatcher {
this.tech_.on('seekablechanged', fixesBadSeeksHandler);
this.tech_.on('waiting', waitingHandler);
this.tech_.on(timerCancelEvents, cancelTimerHandler);
this.monitorCurrentTime_();
if (this.tech_.hasStarted_ || this.tech_.isReady_) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If the tech is not ready by the time this constructor runs, this will continue to be broken. You should setup an event listener for the ready event instead of checking the private variables on the tech. The tech has a this.tech_.ready() function that will either setup a listener for when the ready event will be fired, or will run your callback immediately if the tech is already ready.

let waitingHandler = () => this.techWaiting_();
let cancelTimerHandler = () => this.cancelTimer_();
let fixesBadSeeksHandler = () => this.fixesBadSeeks_();

this.tech_.on('seekablechanged', fixesBadSeeksHandler);
this.tech_.on('waiting', waitingHandler);
this.tech_.on(timerCancelEvents, cancelTimerHandler);
this.monitorCurrentTime_();
this.tech_.on('canplay', canPlayHandler);
Copy link
Contributor

@mjneil mjneil Aug 14, 2017

Choose a reason for hiding this comment

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

you should off the handler in the dispose method below like the other handlers
edit: resolved

@mjneil mjneil merged commit c07e224 into videojs:master Aug 15, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants