src/js/pop.js
author veltr
Tue, 12 Jun 2012 19:44:20 +0200
branchnew-model
changeset 916 ec6849bbbdcc
parent 904 510ebab76fa3
child 917 eb8677d3a663
permissions -rw-r--r--
Removed Namespacing before rewrite
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 
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 841
diff changeset
    11
     preserve them this way */
875
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 870
diff changeset
    12
  if (typeof IriSP._ === "undefined") {
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 870
diff changeset
    13
      return;
43629caa77bc Big refactoring of widget files + started migration of segmentwidget
veltr
parents: 870
diff changeset
    14
  }
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 841
diff changeset
    15
    
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    16
  this.callbacks = {
870
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 841
diff changeset
    17
      onReady:  IriSP._.bind(this.__initApi, this),
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 841
diff changeset
    18
      onTime:   IriSP._.bind(this.__timeHandler, this),
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 841
diff changeset
    19
      onPlay:   IriSP._.bind(this.__playHandler, this),
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 841
diff changeset
    20
      onPause:  IriSP._.bind(this.__pauseHandler, this),
2c025db10a10 Migrated playerWidget and started annotationsListWidget
veltr
parents: 841
diff changeset
    21
      onSeek:   IriSP._.bind(this.__seekHandler, this) 
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    22
  };
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    23
  
699
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    24
  this.media = { 
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    25
    "paused": true,
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    26
    "muted": false
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    27
  };
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    28
    
904
510ebab76fa3 Work on CreateAnnotation Widget
veltr
parents: 875
diff changeset
    29
  this.container = container.replace(/^#/,''); //eschew the '#'
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). */
785
980163a156d1 Added Dailymotion support
veltr
parents: 750
diff changeset
    34
  
980163a156d1 Added Dailymotion support
veltr
parents: 750
diff changeset
    35
  this._options = options;
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    36
                          
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    37
};
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    38
699
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    39
IriSP.PopcornReplacement.player.prototype.listen = function(msg, callback) {
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    40
  if (!this.msgPump.hasOwnProperty(msg))
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    41
    this.msgPump[msg] = [];
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    42
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    43
  this.msgPump[msg].push(callback);
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    44
};
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    45
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    46
IriSP.PopcornReplacement.player.prototype.trigger = function(msg, params) {
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    47
  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
    48
    return;
c2eac11a9053 wrote our own pubsub system because of a bug in the jquery one
hamidouk
parents: 442
diff changeset
    49
699
0d6200d801ad refactoring the pop.js code.
hamidouk
parents: 652
diff changeset
    50
  var d = this.msgPump[msg];
596
a0d2c5b96bee style fix.
hamidouk
parents: 586
diff changeset
    51
586
a3705fc7e054 stylistic rewrite.
hamidouk
parents: 580
diff changeset
    52
  for(var i = 0; i < d.length; i++) {
a3705fc7e054 stylistic rewrite.
hamidouk
parents: 580
diff changeset
    53
    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
    54
  }
c2eac11a9053 wrote our own pubsub system because of a bug in the jquery one
hamidouk
parents: 442
diff changeset
    55
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    56
};
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    57
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    58
IriSP.PopcornReplacement.player.prototype.guid = function(prefix) {
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    59
  var str = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    60
      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
    61
      return v.toString(16);
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    62
   });
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
  return prefix + str;
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    65
};
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    66
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    67
/** init the api after that flash player has been setup - called by the callback
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    68
    defined by the embedded flash player 
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    69
*/
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    70
IriSP.PopcornReplacement.player.prototype.__initApi = function() {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    71
  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
    72
                                                      // but popcorn doesn't need to know more.
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    73
  this.media.muted = this.playerFns.getMute();
578
8dd6ebb7a79d fixed .code() bug.
hamidouk
parents: 477
diff changeset
    74
  /* some programmed segments are supposed to be run at the beginning */
8dd6ebb7a79d fixed .code() bug.
hamidouk
parents: 477
diff changeset
    75
  var i = 0;
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    76
  for(i = 0; i < this.__codes.length; i++) {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    77
    var c = this.__codes[i];
578
8dd6ebb7a79d fixed .code() bug.
hamidouk
parents: 477
diff changeset
    78
    if (0 == c.start) {
8dd6ebb7a79d fixed .code() bug.
hamidouk
parents: 477
diff changeset
    79
      c.onStart();
8dd6ebb7a79d fixed .code() bug.
hamidouk
parents: 477
diff changeset
    80
    }
8dd6ebb7a79d fixed .code() bug.
hamidouk
parents: 477
diff changeset
    81
    
8dd6ebb7a79d fixed .code() bug.
hamidouk
parents: 477
diff changeset
    82
    if (0 == c.end) {
8dd6ebb7a79d fixed .code() bug.
hamidouk
parents: 477
diff changeset
    83
      c.onEnd();
8dd6ebb7a79d fixed .code() bug.
hamidouk
parents: 477
diff changeset
    84
    }
8dd6ebb7a79d fixed .code() bug.
hamidouk
parents: 477
diff changeset
    85
  }
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    86
};
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    87
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    88
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
    89
  if (typeof(time) === "undefined") {        
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    90
      return this.playerFns.getPosition();            
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    91
  } else {
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    92
     var currentTime = +time;
723
bbf9914a5f99 fixed bug
hamidouk
parents: 711
diff changeset
    93
     this.playerFns.seek(currentTime);              
604
cc2208986a4d WIP - trying to fix a seeking bug.
hamidouk
parents: 596
diff changeset
    94
     return currentTime;
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    95
  }
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    96
};
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    97
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    98
IriSP.PopcornReplacement.player.prototype.play = function() {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
    99
  this.media.paused = false;
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   100
  this.trigger("play");
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   101
  //IriSP.PopcornReplacement.trigger("playing");
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   102
  this.playerFns.play();
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
   103
};
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
   104
    
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   105
IriSP.PopcornReplacement.player.prototype.pause = function() {
841
8da49ff273e0 Modifs cinecast
veltr
parents: 839
diff changeset
   106
//  if ( !this.media.paused ) {
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   107
    this.media.paused = true;
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   108
    this.trigger( "pause" );
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   109
    this.playerFns.pause();
841
8da49ff273e0 Modifs cinecast
veltr
parents: 839
diff changeset
   110
//  }
390
9b4e5f606d72 first draft, a little rough around the edges.
hamidouk
parents: 388
diff changeset
   111
};
9b4e5f606d72 first draft, a little rough around the edges.
hamidouk
parents: 388
diff changeset
   112
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   113
IriSP.PopcornReplacement.player.prototype.muted = function(val) {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   114
  if (typeof(val) !== "undefined") {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   115
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   116
    if (this.playerFns.getMute() !== val) {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   117
      if (val) {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   118
        this.playerFns.setMute(true);
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   119
        this.media.muted = true;
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   120
      } else {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   121
        this.playerFns.setMute(false);
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   122
        this.media.muted = false;
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   123
      }
394
89a79a2c6014 WIP - working on the code function.
hamidouk
parents: 391
diff changeset
   124
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   125
      this.trigger( "volumechange" );
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   126
    }
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   127
    
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   128
    return this.playerFns.getMute();
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   129
  } else {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   130
    return this.playerFns.getMute();
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   131
  }
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   132
};
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   133
839
4357aac4eb19 Added volume support
veltr
parents: 785
diff changeset
   134
IriSP.PopcornReplacement.player.prototype.volume = function(val) {
4357aac4eb19 Added volume support
veltr
parents: 785
diff changeset
   135
    if (typeof this.playerFns.getVolume == "undefined" || typeof this.playerFns.setVolume == "undefined") {
4357aac4eb19 Added volume support
veltr
parents: 785
diff changeset
   136
        return false;
4357aac4eb19 Added volume support
veltr
parents: 785
diff changeset
   137
    }
4357aac4eb19 Added volume support
veltr
parents: 785
diff changeset
   138
    var _vol = this.playerFns.getVolume();
4357aac4eb19 Added volume support
veltr
parents: 785
diff changeset
   139
    if (typeof(val) !== "undefined" && parseFloat(val) !== NaN) {
4357aac4eb19 Added volume support
veltr
parents: 785
diff changeset
   140
        val = Math.max(0, Math.min(1, val));
4357aac4eb19 Added volume support
veltr
parents: 785
diff changeset
   141
        if (parseFloat(val) != parseFloat(_vol)) {
4357aac4eb19 Added volume support
veltr
parents: 785
diff changeset
   142
            this.playerFns.setVolume(val);
4357aac4eb19 Added volume support
veltr
parents: 785
diff changeset
   143
            this.trigger("volumechange");
4357aac4eb19 Added volume support
veltr
parents: 785
diff changeset
   144
            _vol = this.playerFns.getVolume();
4357aac4eb19 Added volume support
veltr
parents: 785
diff changeset
   145
        }
4357aac4eb19 Added volume support
veltr
parents: 785
diff changeset
   146
    }
4357aac4eb19 Added volume support
veltr
parents: 785
diff changeset
   147
    return _vol;
4357aac4eb19 Added volume support
veltr
parents: 785
diff changeset
   148
};
4357aac4eb19 Added volume support
veltr
parents: 785
diff changeset
   149
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   150
IriSP.PopcornReplacement.player.prototype.mute = IriSP.PopcornReplacement.player.prototype.muted;
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   151
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   152
IriSP.PopcornReplacement.player.prototype.code = function(options) {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   153
  this.__codes.push(options);
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   154
  return this;
390
9b4e5f606d72 first draft, a little rough around the edges.
hamidouk
parents: 388
diff changeset
   155
};
9b4e5f606d72 first draft, a little rough around the edges.
hamidouk
parents: 388
diff changeset
   156
394
89a79a2c6014 WIP - working on the code function.
hamidouk
parents: 391
diff changeset
   157
/* called everytime the player updates itself 
89a79a2c6014 WIP - working on the code function.
hamidouk
parents: 391
diff changeset
   158
   (onTime event)
89a79a2c6014 WIP - working on the code function.
hamidouk
parents: 391
diff changeset
   159
 */
89a79a2c6014 WIP - working on the code function.
hamidouk
parents: 391
diff changeset
   160
706
a759113f6bd1 renamed a bunch of global functions.
hamidouk
parents: 702
diff changeset
   161
IriSP.PopcornReplacement.player.prototype.__timeHandler = function(event) {
417
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   162
  var pos = event.position;
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   163
417
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   164
  var i = 0;
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   165
  for(i = 0; i < this.__codes.length; i++) {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   166
     var c = this.__codes[i];
580
47fb5cd44900 fixed a couple .code() bugs.
hamidouk
parents: 578
diff changeset
   167
417
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   168
     if (pos >= c.start && pos < c.end && 
580
47fb5cd44900 fixed a couple .code() bugs.
hamidouk
parents: 578
diff changeset
   169
         pos - 1 <= c.start) {       
417
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   170
        c.onStart();
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   171
     }
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   172
 
475
5c254621cd9c fixed popcorn replacement bug where onEnd would be called after onStart.
hamidouk
parents: 463
diff changeset
   173
     if (pos > c.start && pos > c.end && 
580
47fb5cd44900 fixed a couple .code() bugs.
hamidouk
parents: 578
diff changeset
   174
         pos - 1 <= c.end) {
578
8dd6ebb7a79d fixed .code() bug.
hamidouk
parents: 477
diff changeset
   175
         c.onEnd();
417
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
  }
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   179
 
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   180
  this.trigger("timeupdate");
390
9b4e5f606d72 first draft, a little rough around the edges.
hamidouk
parents: 388
diff changeset
   181
};
394
89a79a2c6014 WIP - working on the code function.
hamidouk
parents: 391
diff changeset
   182
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   183
IriSP.PopcornReplacement.player.prototype.__seekHandler = function(event) {
417
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   184
  var i = 0;
723
bbf9914a5f99 fixed bug
hamidouk
parents: 711
diff changeset
   185
  
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   186
  for(i = 0; i < this.__codes.length; i++) {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   187
     var c = this.__codes[i];
417
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   188
    
475
5c254621cd9c fixed popcorn replacement bug where onEnd would be called after onStart.
hamidouk
parents: 463
diff changeset
   189
     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
   190
        c.onEnd();
475
5c254621cd9c fixed popcorn replacement bug where onEnd would be called after onStart.
hamidouk
parents: 463
diff changeset
   191
     }         
5c254621cd9c fixed popcorn replacement bug where onEnd would be called after onStart.
hamidouk
parents: 463
diff changeset
   192
   }
580
47fb5cd44900 fixed a couple .code() bugs.
hamidouk
parents: 578
diff changeset
   193
  
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   194
   for(i = 0; i < this.__codes.length; i++) {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   195
     var c = this.__codes[i];
475
5c254621cd9c fixed popcorn replacement bug where onEnd would be called after onStart.
hamidouk
parents: 463
diff changeset
   196
417
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   197
     if (typeof(event.offset) === "undefined")
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   198
       event.offset = 0;
475
5c254621cd9c fixed popcorn replacement bug where onEnd would be called after onStart.
hamidouk
parents: 463
diff changeset
   199
           
5c254621cd9c fixed popcorn replacement bug where onEnd would be called after onStart.
hamidouk
parents: 463
diff changeset
   200
     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
   201
       c.onStart();
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
     
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   204
   }
723
bbf9914a5f99 fixed bug
hamidouk
parents: 711
diff changeset
   205
  
750
a1a3d09de1f4 added comment.
hamidouk
parents: 749
diff changeset
   206
  /* this signal sends as an extra argument the position in the video.
a1a3d09de1f4 added comment.
hamidouk
parents: 749
diff changeset
   207
     As far as I know, this argument is not provided by popcorn */
749
e9ee52225395 fixed seeking bug.
hamidouk
parents: 723
diff changeset
   208
  this.trigger("seeked", event.offset);  
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   209
};
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   210
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   211
IriSP.PopcornReplacement.player.prototype.__playHandler = function(event) {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   212
  this.media.paused = false;
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   213
  this.trigger("play");
441
99b7c5192330 fixed horrible bug involving jQuery message passing.
hamidouk
parents: 431
diff changeset
   214
};
99b7c5192330 fixed horrible bug involving jQuery message passing.
hamidouk
parents: 431
diff changeset
   215
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   216
IriSP.PopcornReplacement.player.prototype.__pauseHandler = function(event) {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   217
  this.media.paused = true;
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   218
  this.trigger("pause");
441
99b7c5192330 fixed horrible bug involving jQuery message passing.
hamidouk
parents: 431
diff changeset
   219
};
99b7c5192330 fixed horrible bug involving jQuery message passing.
hamidouk
parents: 431
diff changeset
   220
702
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   221
IriSP.PopcornReplacement.player.prototype.roundTime = function() {
f1225d38c150 new, extendable api.
hamidouk
parents: 699
diff changeset
   222
  var currentTime = this.currentTime();
394
89a79a2c6014 WIP - working on the code function.
hamidouk
parents: 391
diff changeset
   223
  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
   224
};