src/js/pop.js
branchpopcorn-port
changeset 604 cc2208986a4d
parent 596 a0d2c5b96bee
child 605 e1a6f73038b4
equal deleted inserted replaced
603:58dfdafb5410 604:cc2208986a4d
     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
       
     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
     6 };
    11 };
     7 
    12 
     8 IriSP.PopcornReplacement.media = { 
    13 IriSP.PopcornReplacement.media = { 
     9   "paused": true,
    14   "paused": true,
    10   "muted": false
    15   "muted": false
    75   return IriSP.PopcornReplacement;
    80   return IriSP.PopcornReplacement;
    76 };
    81 };
    77 
    82 
    78 IriSP.PopcornReplacement.currentTime = function(time) {
    83 IriSP.PopcornReplacement.currentTime = function(time) {
    79   if (typeof(time) === "undefined") {
    84   if (typeof(time) === "undefined") {
       
    85       if (IriSP.PopcornReplacement.__faking === true) {
       
    86         return IriSP.PopcornReplacement.__fake_currentTime;
       
    87       }
       
    88         
    80       return jwplayer(IriSP.PopcornReplacement._container).getPosition();            
    89       return jwplayer(IriSP.PopcornReplacement._container).getPosition();            
    81   } else {
    90   } else {
    82      var currentTime = +time;
    91      var currentTime = +time;
    83      jwplayer( IriSP.PopcornReplacement._container ).seek( currentTime );
    92      jwplayer( IriSP.PopcornReplacement._container ).seek( currentTime );
       
    93      IriSP.PopcornReplacement.__fake_currentTime = currentTime;
    84      IriSP.PopcornReplacement.trigger("seeked");
    94      IriSP.PopcornReplacement.trigger("seeked");
    85      return jwplayer(IriSP.PopcornReplacement._container).getPosition();            
    95      //return jwplayer(IriSP.PopcornReplacement._container).getPosition();            
       
    96      return currentTime;
    86   }
    97   }
    87 };
    98 };
    88 
    99 
    89 IriSP.PopcornReplacement.play = function() {
   100 IriSP.PopcornReplacement.play = function() {
    90       IriSP.PopcornReplacement.media.paused = false;
   101       IriSP.PopcornReplacement.media.paused = false;
   182   IriSP.PopcornReplacement.trigger("timeupdate");
   193   IriSP.PopcornReplacement.trigger("timeupdate");
   183 };
   194 };
   184 
   195 
   185 
   196 
   186 IriSP.PopcornReplacement.__playHandler = function(event) {
   197 IriSP.PopcornReplacement.__playHandler = function(event) {
       
   198   if (IriSP.PopcornReplacement.__faking === true)
       
   199     IriSP.PopcornReplacement.__faking = false;
       
   200   
   187   IriSP.PopcornReplacement.media.paused = false;
   201   IriSP.PopcornReplacement.media.paused = false;
   188   IriSP.PopcornReplacement.trigger("play");
   202   IriSP.PopcornReplacement.trigger("play");
   189 };
   203 };
   190 
   204 
   191 IriSP.PopcornReplacement.__pauseHandler = function(event) {
   205 IriSP.PopcornReplacement.__pauseHandler = function(event) {