src/js/pop.js
branchpopcorn-port
changeset 605 e1a6f73038b4
parent 604 cc2208986a4d
child 612 5292f847b43a
equal deleted inserted replaced
604:cc2208986a4d 605:e1a6f73038b4
     1 /* wrapper that simulates popcorn.js because
     1 /* wrapper that simulates popcorn.js because
     2    popcorn is a bit unstable at the time */
     2    popcorn is a bit unstable at the time */
     3 
     3 
     4 IriSP.PopcornReplacement = {
     4 IriSP.PopcornReplacement = {
     5   msgPump : {} /* used by jquery to receive and send messages */,
     5   msgPump : {} /* used by jquery to receive and send messages */,
     6   __fake_currentTime : 0, /* when the stream is too slow, some events which depend
     6   __delay_seek_signal : false
     7                      on event "seeked" react to quickly and pickup the wrong currentTime.
       
     8                      That's why we store the future currentTime in a var until the player
       
     9                      has finished seeking */
       
    10   __faking : false
       
    11 };
     7 };
    12 
     8 
    13 IriSP.PopcornReplacement.media = { 
     9 IriSP.PopcornReplacement.media = { 
    14   "paused": true,
    10   "paused": true,
    15   "muted": false
    11   "muted": false
    79   IriSP.PopcornReplacement.media.duration = options.duration;
    75   IriSP.PopcornReplacement.media.duration = options.duration;
    80   return IriSP.PopcornReplacement;
    76   return IriSP.PopcornReplacement;
    81 };
    77 };
    82 
    78 
    83 IriSP.PopcornReplacement.currentTime = function(time) {
    79 IriSP.PopcornReplacement.currentTime = function(time) {
    84   if (typeof(time) === "undefined") {
    80   if (typeof(time) === "undefined") {        
    85       if (IriSP.PopcornReplacement.__faking === true) {
       
    86         return IriSP.PopcornReplacement.__fake_currentTime;
       
    87       }
       
    88         
       
    89       return jwplayer(IriSP.PopcornReplacement._container).getPosition();            
    81       return jwplayer(IriSP.PopcornReplacement._container).getPosition();            
    90   } else {
    82   } else {
    91      var currentTime = +time;
    83      var currentTime = +time;
    92      jwplayer( IriSP.PopcornReplacement._container ).seek( currentTime );
    84      jwplayer( IriSP.PopcornReplacement._container ).seek( currentTime );
    93      IriSP.PopcornReplacement.__fake_currentTime = currentTime;
    85      IriSP.PopcornReplacement.__delay_seek_signal = true;     
    94      IriSP.PopcornReplacement.trigger("seeked");
       
    95      //return jwplayer(IriSP.PopcornReplacement._container).getPosition();            
    86      //return jwplayer(IriSP.PopcornReplacement._container).getPosition();            
    96      return currentTime;
    87      return currentTime;
    97   }
    88   }
    98 };
    89 };
    99 
    90 
   188        c.onStart();
   179        c.onStart();
   189      }
   180      }
   190      
   181      
   191    }
   182    }
   192 
   183 
       
   184   if (IriSP.PopcornReplacement.__delay_seek_signal === true) {
       
   185     console.log(IriSP.PopcornReplacement.currentTime());
       
   186     IriSP.PopcornReplacement.trigger("seeked");
       
   187   }
   193   IriSP.PopcornReplacement.trigger("timeupdate");
   188   IriSP.PopcornReplacement.trigger("timeupdate");
   194 };
   189 };
   195 
   190 
   196 
   191 
   197 IriSP.PopcornReplacement.__playHandler = function(event) {
   192 IriSP.PopcornReplacement.__playHandler = function(event) {
   198   if (IriSP.PopcornReplacement.__faking === true)
       
   199     IriSP.PopcornReplacement.__faking = false;
       
   200   
       
   201   IriSP.PopcornReplacement.media.paused = false;
   193   IriSP.PopcornReplacement.media.paused = false;
   202   IriSP.PopcornReplacement.trigger("play");
   194   IriSP.PopcornReplacement.trigger("play");
   203 };
   195 };
   204 
   196 
   205 IriSP.PopcornReplacement.__pauseHandler = function(event) {
   197 IriSP.PopcornReplacement.__pauseHandler = function(event) {