src/js/pop.js
author veltr
Thu, 22 Mar 2012 18:42:31 +0100
branchpopcorn-port
changeset 837 353a78021ebc
parent 785 980163a156d1
child 839 4357aac4eb19
permissions -rw-r--r--
Added Internationalization
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
387
d1fe53ad8d72 initial commit
hamidouk
parents:
diff changeset
     1
/* wrapper that simulates popcorn.js because
d1fe53ad8d72 initial commit
hamidouk
parents:
diff changeset
     2
   popcorn is a bit unstable at the time */
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
     3
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
     4
IriSP.PopcornReplacement = {  
442
ee6594f6d00d play pause that just works (tm)
hamidouk
parents: 441
diff changeset
     5
};
390
9b4e5f606d72 first draft, a little rough around the edges.
hamidouk
parents: 388
diff changeset
     6
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
     7
/** base class for our popcorn-compatible players.
699
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
     8
 */
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
     9
IriSP.PopcornReplacement.player = function(container, options) {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    10
  /* the jwplayer calls the callbacks in the global space so we need to 
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    11
     preserve them using IriSP.wrap */
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    12
  this.callbacks = {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    13
      onReady:  IriSP.wrap(this, this.__initApi),
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    14
      onTime:   IriSP.wrap(this, this.__timeHandler),
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    15
      onPlay:   IriSP.wrap(this, this.__playHandler),
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    16
      onPause:  IriSP.wrap(this, this.__pauseHandler),
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    17
      onSeek:   IriSP.wrap(this, this.__seekHandler) 
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    18
  };
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    19
  
699
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    20
  this.media = { 
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    21
    "paused": true,
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    22
    "muted": false
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    23
  };
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    24
    
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    25
  this.container = container.slice(1); //eschew the '#'
699
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    26
  
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    27
  this.msgPump = {}; /* dictionnary used to receive and send messages */
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    28
  this.__codes = []; /* used to schedule the execution of a piece of code in 
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    29
                        a segment (similar to the popcorn.code plugin). */
785
980163a156d1 Added Dailymotion support
veltr
parents: 750
diff changeset
    30
  
980163a156d1 Added Dailymotion support
veltr
parents: 750
diff changeset
    31
  this._options = options;
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    32
                          
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    33
};
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    34
699
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    35
IriSP.PopcornReplacement.player.prototype.listen = function(msg, callback) {
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    36
  if (!this.msgPump.hasOwnProperty(msg))
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    37
    this.msgPump[msg] = [];
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    38
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    39
  this.msgPump[msg].push(callback);
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    40
};
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    41
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    42
IriSP.PopcornReplacement.player.prototype.trigger = function(msg, params) {
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    43
  if (!this.msgPump.hasOwnProperty(msg))
445
c2eac11a9053 wrote our own pubsub system because of a bug in the jquery one
hamidouk
parents: 442
diff changeset
    44
    return;
c2eac11a9053 wrote our own pubsub system because of a bug in the jquery one
hamidouk
parents: 442
diff changeset
    45
699
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    46
  var d = this.msgPump[msg];
596
a0d2c5b96bee style fix.
hamidouk
parents: 586
diff changeset
    47
586
a3705fc7e054 stylistic rewrite.
hamidouk
parents: 580
diff changeset
    48
  for(var i = 0; i < d.length; i++) {
a3705fc7e054 stylistic rewrite.
hamidouk
parents: 580
diff changeset
    49
    d[i].call(window, params);
445
c2eac11a9053 wrote our own pubsub system because of a bug in the jquery one
hamidouk
parents: 442
diff changeset
    50
  }
c2eac11a9053 wrote our own pubsub system because of a bug in the jquery one
hamidouk
parents: 442
diff changeset
    51
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    52
};
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    53
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    54
IriSP.PopcornReplacement.player.prototype.guid = function(prefix) {
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    55
  var str = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    56
      var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    57
      return v.toString(16);
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    58
   });
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    59
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    60
  return prefix + str;
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    61
};
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    62
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    63
/** init the api after that flash player has been setup - called by the callback
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    64
    defined by the embedded flash player 
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    65
*/
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    66
IriSP.PopcornReplacement.player.prototype.__initApi = function() {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    67
  this.trigger("loadedmetadata"); // we've done more than loading metadata of course,
463
7ef123b2410f trigger a bunch of signals for popcorn compatibility.
hamidouk
parents: 458
diff changeset
    68
                                                      // but popcorn doesn't need to know more.
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    69
  this.media.muted = this.playerFns.getMute();
578
8dd6ebb7a79d fixed .code() bug.
hamidouk
parents: 477
diff changeset
    70
  /* some programmed segments are supposed to be run at the beginning */
8dd6ebb7a79d fixed .code() bug.
hamidouk
parents: 477
diff changeset
    71
  var i = 0;
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    72
  for(i = 0; i < this.__codes.length; i++) {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    73
    var c = this.__codes[i];
578
8dd6ebb7a79d fixed .code() bug.
hamidouk
parents: 477
diff changeset
    74
    if (0 == c.start) {
8dd6ebb7a79d fixed .code() bug.
hamidouk
parents: 477
diff changeset
    75
      c.onStart();
8dd6ebb7a79d fixed .code() bug.
hamidouk
parents: 477
diff changeset
    76
    }
8dd6ebb7a79d fixed .code() bug.
hamidouk
parents: 477
diff changeset
    77
    
8dd6ebb7a79d fixed .code() bug.
hamidouk
parents: 477
diff changeset
    78
    if (0 == c.end) {
8dd6ebb7a79d fixed .code() bug.
hamidouk
parents: 477
diff changeset
    79
      c.onEnd();
8dd6ebb7a79d fixed .code() bug.
hamidouk
parents: 477
diff changeset
    80
    }
8dd6ebb7a79d fixed .code() bug.
hamidouk
parents: 477
diff changeset
    81
  }
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    82
};
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    83
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    84
/*
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    85
IriSP.PopcornReplacement.jwplayer = function(container, options) {
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    86
  IriSP.PopcornReplacement._container = container.slice(1); //eschew the '#'
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    87
  options.events = {
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    88
      onReady: IriSP.PopcornReplacement.__initApi,
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    89
      onTime: IriSP.PopcornReplacement.__timeHandler,
442
ee6594f6d00d play pause that just works (tm)
hamidouk
parents: 441
diff changeset
    90
      onPlay: IriSP.PopcornReplacement.__playHandler,
ee6594f6d00d play pause that just works (tm)
hamidouk
parents: 441
diff changeset
    91
      onPause: IriSP.PopcornReplacement.__pauseHandler,
441
99b7c5192330 fixed horrible bug involving jQuery message passing.
hamidouk
parents: 431
diff changeset
    92
      onSeek: IriSP.PopcornReplacement.__seekHandler 
99b7c5192330 fixed horrible bug involving jQuery message passing.
hamidouk
parents: 431
diff changeset
    93
      }
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    94
    
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    95
  jwplayer(IriSP.PopcornReplacement._container).setup(options);
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    96
  IriSP.PopcornReplacement.media.duration = options.duration;
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    97
  return IriSP.PopcornReplacement;
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    98
};
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    99
*/
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
   100
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   101
IriSP.PopcornReplacement.player.prototype.currentTime = function(time) {
605
e1a6f73038b4 made the listWidget redraw at every timeupdate event (added a small optimization though,
hamidouk
parents: 604
diff changeset
   102
  if (typeof(time) === "undefined") {        
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   103
      return this.playerFns.getPosition();            
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
   104
  } else {
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
   105
     var currentTime = +time;
723
bbf9914a5f99 fixed bug
hamidouk
parents: 711
diff changeset
   106
     this.playerFns.seek(currentTime);              
604
cc2208986a4d WIP - trying to fix a seeking bug.
hamidouk
parents: 596
diff changeset
   107
     return currentTime;
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
   108
  }
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
   109
};
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
   110
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   111
IriSP.PopcornReplacement.player.prototype.play = function() {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   112
  this.media.paused = false;
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   113
  this.trigger("play");
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   114
  //IriSP.PopcornReplacement.trigger("playing");
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   115
  this.playerFns.play();
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
   116
};
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
   117
    
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   118
IriSP.PopcornReplacement.player.prototype.pause = function() {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   119
  if ( !this.media.paused ) {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   120
    this.media.paused = true;
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   121
    this.trigger( "pause" );
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   122
    this.playerFns.pause();
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
   123
  }
390
9b4e5f606d72 first draft, a little rough around the edges.
hamidouk
parents: 388
diff changeset
   124
};
9b4e5f606d72 first draft, a little rough around the edges.
hamidouk
parents: 388
diff changeset
   125
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   126
IriSP.PopcornReplacement.player.prototype.muted = function(val) {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   127
  if (typeof(val) !== "undefined") {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   128
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   129
    if (this.playerFns.getMute() !== val) {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   130
      if (val) {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   131
        this.playerFns.setMute(true);
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   132
        this.media.muted = true;
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   133
      } else {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   134
        this.playerFns.setMute(false);
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   135
        this.media.muted = false;
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   136
      }
394
89a79a2c6014 WIP - working on the code function.
hamidouk
parents: 391
diff changeset
   137
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   138
      this.trigger( "volumechange" );
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   139
    }
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   140
    
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   141
    return this.playerFns.getMute();
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   142
  } else {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   143
    return this.playerFns.getMute();
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   144
  }
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   145
};
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   146
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   147
IriSP.PopcornReplacement.player.prototype.mute = IriSP.PopcornReplacement.player.prototype.muted;
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   148
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   149
IriSP.PopcornReplacement.player.prototype.code = function(options) {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   150
  this.__codes.push(options);
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   151
  return this;
390
9b4e5f606d72 first draft, a little rough around the edges.
hamidouk
parents: 388
diff changeset
   152
};
9b4e5f606d72 first draft, a little rough around the edges.
hamidouk
parents: 388
diff changeset
   153
394
89a79a2c6014 WIP - working on the code function.
hamidouk
parents: 391
diff changeset
   154
/* called everytime the player updates itself 
89a79a2c6014 WIP - working on the code function.
hamidouk
parents: 391
diff changeset
   155
   (onTime event)
89a79a2c6014 WIP - working on the code function.
hamidouk
parents: 391
diff changeset
   156
 */
89a79a2c6014 WIP - working on the code function.
hamidouk
parents: 391
diff changeset
   157
706
a759113f6bd1 renamed a bunch of global functions.
hamidouk
parents: 702
diff changeset
   158
IriSP.PopcornReplacement.player.prototype.__timeHandler = function(event) {
417
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   159
  var pos = event.position;
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   160
417
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   161
  var i = 0;
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   162
  for(i = 0; i < this.__codes.length; i++) {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   163
     var c = this.__codes[i];
580
47fb5cd44900 fixed a couple .code() bugs.
hamidouk
parents: 578
diff changeset
   164
417
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   165
     if (pos >= c.start && pos < c.end && 
580
47fb5cd44900 fixed a couple .code() bugs.
hamidouk
parents: 578
diff changeset
   166
         pos - 1 <= c.start) {       
417
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   167
        c.onStart();
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   168
     }
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   169
 
475
5c254621cd9c fixed popcorn replacement bug where onEnd would be called after onStart.
hamidouk
parents: 463
diff changeset
   170
     if (pos > c.start && pos > c.end && 
580
47fb5cd44900 fixed a couple .code() bugs.
hamidouk
parents: 578
diff changeset
   171
         pos - 1 <= c.end) {
578
8dd6ebb7a79d fixed .code() bug.
hamidouk
parents: 477
diff changeset
   172
         c.onEnd();
417
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   173
     }
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   174
   
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   175
  }
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   176
 
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   177
  this.trigger("timeupdate");
390
9b4e5f606d72 first draft, a little rough around the edges.
hamidouk
parents: 388
diff changeset
   178
};
394
89a79a2c6014 WIP - working on the code function.
hamidouk
parents: 391
diff changeset
   179
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   180
IriSP.PopcornReplacement.player.prototype.__seekHandler = function(event) {
417
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   181
  var i = 0;
723
bbf9914a5f99 fixed bug
hamidouk
parents: 711
diff changeset
   182
  
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   183
  for(i = 0; i < this.__codes.length; i++) {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   184
     var c = this.__codes[i];
417
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   185
    
475
5c254621cd9c fixed popcorn replacement bug where onEnd would be called after onStart.
hamidouk
parents: 463
diff changeset
   186
     if (event.position >= c.start && event.position < c.end) {        
417
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   187
        c.onEnd();
475
5c254621cd9c fixed popcorn replacement bug where onEnd would be called after onStart.
hamidouk
parents: 463
diff changeset
   188
     }         
5c254621cd9c fixed popcorn replacement bug where onEnd would be called after onStart.
hamidouk
parents: 463
diff changeset
   189
   }
580
47fb5cd44900 fixed a couple .code() bugs.
hamidouk
parents: 578
diff changeset
   190
  
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   191
   for(i = 0; i < this.__codes.length; i++) {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   192
     var c = this.__codes[i];
475
5c254621cd9c fixed popcorn replacement bug where onEnd would be called after onStart.
hamidouk
parents: 463
diff changeset
   193
417
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   194
     if (typeof(event.offset) === "undefined")
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   195
       event.offset = 0;
475
5c254621cd9c fixed popcorn replacement bug where onEnd would be called after onStart.
hamidouk
parents: 463
diff changeset
   196
           
5c254621cd9c fixed popcorn replacement bug where onEnd would be called after onStart.
hamidouk
parents: 463
diff changeset
   197
     if (event.offset >= c.start && event.offset < c.end) { 
417
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   198
       c.onStart();
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   199
     }
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   200
     
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   201
   }
723
bbf9914a5f99 fixed bug
hamidouk
parents: 711
diff changeset
   202
  
750
a1a3d09de1f4 added comment.
hamidouk
parents: 749
diff changeset
   203
  /* this signal sends as an extra argument the position in the video.
a1a3d09de1f4 added comment.
hamidouk
parents: 749
diff changeset
   204
     As far as I know, this argument is not provided by popcorn */
749
e9ee52225395 fixed seeking bug.
hamidouk
parents: 723
diff changeset
   205
  this.trigger("seeked", event.offset);  
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   206
};
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   207
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   208
IriSP.PopcornReplacement.player.prototype.__playHandler = function(event) {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   209
  this.media.paused = false;
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   210
  this.trigger("play");
441
99b7c5192330 fixed horrible bug involving jQuery message passing.
hamidouk
parents: 431
diff changeset
   211
};
99b7c5192330 fixed horrible bug involving jQuery message passing.
hamidouk
parents: 431
diff changeset
   212
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   213
IriSP.PopcornReplacement.player.prototype.__pauseHandler = function(event) {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   214
  this.media.paused = true;
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   215
  this.trigger("pause");
441
99b7c5192330 fixed horrible bug involving jQuery message passing.
hamidouk
parents: 431
diff changeset
   216
};
99b7c5192330 fixed horrible bug involving jQuery message passing.
hamidouk
parents: 431
diff changeset
   217
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   218
IriSP.PopcornReplacement.player.prototype.roundTime = function() {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   219
  var currentTime = this.currentTime();
394
89a79a2c6014 WIP - working on the code function.
hamidouk
parents: 391
diff changeset
   220
  return Math.round(currentTime);
711
323205a7bd39 separated jwplayer code from pop.js and put it into its own folder, players/.
hamidouk
parents: 706
diff changeset
   221
};