mozilla / popcorn-js

The HTML5 Media Framework. (Unmaintained. See https://github.com/menismu/popcorn-js for activity)
MIT License
2.14k stars 632 forks source link

Vimeo onPlayerReady broken: no event fires on load #463

Open goingonit opened 8 years ago

goingonit commented 8 years ago

Browser info: Chrome on MacOS [Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36]

The HTMLVimeoVideoElement tries to do a play/pause cycle on load but on my machine this only pauses. Issues are fixed by eliminating the play/pause cycle but then presumably whatever bug this was introduced for would come back?

liveaspankaj commented 8 years ago

I am facing an odd issue, but may be related.

on first clicking Play, the Play event is not fired, infact even onPlayerReady event is also not fired. Then when I click on Pause and again Play. Then Play event is fired.

It started few days back, so it could be related and could be due to some change in Vimeo API?

Where did you make the change you are talking about, I could not find the play/pause cycle on load?

liveaspankaj commented 8 years ago

This is a temporary fix I did to fix the issue: Not sure if its best way to do it?

--- a/popcorn-complete.js
+++ b/popcorn-complete.js
@@ -5292,7 +5292,8 @@
       playerReadyCallbacks = [],
       timeUpdateInterval,
       currentTimeInterval,
-      lastCurrentTime = 0;
+      lastCurrentTime = 0,
+       play = false;

     // Namespace all events we'll produce
     self._eventNamespace = Popcorn.guid( "HTMLVimeoVideoElement::" );
@@ -5516,6 +5517,13 @@
           if( duration > 0 && !playerReady ) {
             playerReady = true;
             player.pause();
+
+                 player.setVolume( 1 );
+                 // Switch message pump to use run-time message callback vs. startup
+                 window.removeEventListener( "message", startupMessage, false );
+                 window.addEventListener( "message", onStateChange, false );
+                 onPlayerReady();
+
           }
           break;
         case "pause":
@@ -5564,6 +5572,10 @@
           updateDuration( parseFloat( data.data.duration ) );
           break;
         case "playProgress":
+         if(!play && data.data.seconds > 0) {
+               play = true;
+               onPlay();
+         }
           onCurrentTime( parseFloat( data.data.seconds ) );
           break;
         case "play":