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