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

Race canplay event with a setTimeout. #136

Merged
merged 7 commits into from
Dec 11, 2015
Merged

Race canplay event with a setTimeout. #136

merged 7 commits into from
Dec 11, 2015

Conversation

gkatsev
Copy link
Member

@gkatsev gkatsev commented Dec 10, 2015

In some browsers, like firefox with MSE, canplay doesn't fire at the
correct time. So, we need to race it against a setTimeout so that we
would actually try to resume if canplay doesn't fire correctly.
In the tryToResume function we then clear out the event handler and the
timeout depending on which came back first.

Also, see videojs/videojs-contrib-hls#469

In some browsers, like firefox with MSE, canplay doesn't fire at the
correct time. So, we need to race it against a setTimeout so that we
would actually try to resume if canplay doesn't fire correctly.
In the tryToResume function we then clear out the event handler and the
timeout depending on which came back first.
player.one('contentcanplay', tryToResume);
player.ads.tryToResumeTimeout = player.setTimeout(tryToResume, 2000);
Copy link
Member Author

Choose a reason for hiding this comment

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

I used 2 seconds here. I'm not sure what this should actually be.

Copy link
Member

Choose a reason for hiding this comment

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

Probably should suffix this with an underscore so it's obvious it's an internal variable.

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@dmlap
Copy link
Member

dmlap commented Dec 10, 2015

One comment about variable naming but otherwise LGTM

dmlap added a commit that referenced this pull request Dec 11, 2015
Race canplay event with a setTimeout.
@dmlap dmlap merged commit 9c3f83d into master Dec 11, 2015
@dmlap dmlap deleted the trytoresume branch December 11, 2015 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants