Skip to content
This repository has been archived by the owner on Jun 29, 2018. It is now read-only.

Workaround for missing pause event in Youtube on Chrome #460

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

syl22-00
Copy link
Contributor

This is a fix for issue #458 where the pause event is not fired in Youtube HTML on Chrome, meaning that player initialization does not complete.

@ScottDowne
Copy link
Contributor

Hm, interesting.

How do we know for sure that the settimeout fires after it is paused? I also wonder what happened with youtube and chrome to cause this breakage.

@syl22-00
Copy link
Contributor Author

The pauseVideo() call does not change the state to paused, so we can not checked whether the video is actually paused after the timeout fires. One possibility could be to check if time changes or not, adding further delay. So I just assumed 0.2 seconds is safe enough.

As for what happened to Youtube (nothing probably changed on Chrome as issue is consistent across versions), I have no idea and did not find anything. But the issue has been here for more than a week I think.

@ScottDowne
Copy link
Contributor

Yeah, it does seem like something changed on YouTube's end, which doesn't surprise me at all. It sounds like a bug on YouTube's end.

What happens if you delay this call by 0-200 ms https://github.com/pculture/popcorn-js/blob/master/wrappers/youtube/popcorn.HTMLYouTubeVideoElement.js#L248

@syl22-00
Copy link
Contributor Author

Delaying the call to pause does not fix the missing pause event.

Actually my fix was really wrong (the parameter sent to onFirstPause was actually not sent) but was still working because the pause call is apparently synchronous, unlike the call to seek, which the onFirstPause function makes sure completes before proceeding. So I updated the fix, completely taking out waiting for that event. It works well on Chrome and Firefox.

@ScottDowne
Copy link
Contributor

I'm not super comfortable with accepting this yet, until we have a better idea why this broke.

That might give us more insight, and lead us to a cleaner fix.

Right now it is actually just circumventing the pause event completely.

@syl22-00
Copy link
Contributor Author

syl22-00 commented Aug 4, 2015

This is not necessary anymore as youtube seems to have fixed the missing event.

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

Successfully merging this pull request may close these issues.

2 participants