src/js/pop.js
author hamidouk
Fri, 09 Dec 2011 16:07:30 +0100
branchpopcorn-port
changeset 448 fa9400275846
parent 445 c2eac11a9053
child 458 5bafddd9e3ba
permissions -rw-r--r--
added a volume boolen in media.
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
445
c2eac11a9053 wrote our own pubsub system because of a bug in the jquery one
hamidouk
parents: 442
diff changeset
     4
IriSP.PopcornReplacement = {
c2eac11a9053 wrote our own pubsub system because of a bug in the jquery one
hamidouk
parents: 442
diff changeset
     5
  msgPump : {} /* used by jquery to receive and send messages */
c2eac11a9053 wrote our own pubsub system because of a bug in the jquery one
hamidouk
parents: 442
diff changeset
     6
};
c2eac11a9053 wrote our own pubsub system because of a bug in the jquery one
hamidouk
parents: 442
diff changeset
     7
442
ee6594f6d00d play pause that just works (tm)
hamidouk
parents: 441
diff changeset
     8
IriSP.PopcornReplacement.media = { 
448
fa9400275846 added a volume boolen in media.
hamidouk
parents: 445
diff changeset
     9
  "paused": true,
fa9400275846 added a volume boolen in media.
hamidouk
parents: 445
diff changeset
    10
  "muted": false
442
ee6594f6d00d play pause that just works (tm)
hamidouk
parents: 441
diff changeset
    11
};
390
9b4e5f606d72 first draft, a little rough around the edges.
hamidouk
parents: 388
diff changeset
    12
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    13
IriSP.PopcornReplacement.listen = function(msg, callback) {
445
c2eac11a9053 wrote our own pubsub system because of a bug in the jquery one
hamidouk
parents: 442
diff changeset
    14
//  IriSP.jQuery(IriSP.PopcornReplacement.msgPump).bind(msg, function(event, rest) { callback(rest); });
c2eac11a9053 wrote our own pubsub system because of a bug in the jquery one
hamidouk
parents: 442
diff changeset
    15
  if (!IriSP.PopcornReplacement.msgPump.hasOwnProperty(msg))
c2eac11a9053 wrote our own pubsub system because of a bug in the jquery one
hamidouk
parents: 442
diff changeset
    16
    IriSP.PopcornReplacement.msgPump[msg] = [];
c2eac11a9053 wrote our own pubsub system because of a bug in the jquery one
hamidouk
parents: 442
diff changeset
    17
c2eac11a9053 wrote our own pubsub system because of a bug in the jquery one
hamidouk
parents: 442
diff changeset
    18
  IriSP.PopcornReplacement.msgPump[msg].push(callback);
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    19
};
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    20
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    21
IriSP.PopcornReplacement.trigger = function(msg, params) {
445
c2eac11a9053 wrote our own pubsub system because of a bug in the jquery one
hamidouk
parents: 442
diff changeset
    22
//  IriSP.jQuery(IriSP.PopcornReplacement.msgPump).trigger(msg, params);
c2eac11a9053 wrote our own pubsub system because of a bug in the jquery one
hamidouk
parents: 442
diff changeset
    23
  
c2eac11a9053 wrote our own pubsub system because of a bug in the jquery one
hamidouk
parents: 442
diff changeset
    24
  if (!IriSP.PopcornReplacement.msgPump.hasOwnProperty(msg))
c2eac11a9053 wrote our own pubsub system because of a bug in the jquery one
hamidouk
parents: 442
diff changeset
    25
    return;
c2eac11a9053 wrote our own pubsub system because of a bug in the jquery one
hamidouk
parents: 442
diff changeset
    26
c2eac11a9053 wrote our own pubsub system because of a bug in the jquery one
hamidouk
parents: 442
diff changeset
    27
  var d = IriSP.PopcornReplacement.msgPump[msg];
c2eac11a9053 wrote our own pubsub system because of a bug in the jquery one
hamidouk
parents: 442
diff changeset
    28
  for(var entry in d) {
c2eac11a9053 wrote our own pubsub system because of a bug in the jquery one
hamidouk
parents: 442
diff changeset
    29
    d[entry].call(window, params);
c2eac11a9053 wrote our own pubsub system because of a bug in the jquery one
hamidouk
parents: 442
diff changeset
    30
  }
c2eac11a9053 wrote our own pubsub system because of a bug in the jquery one
hamidouk
parents: 442
diff changeset
    31
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    32
};
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    33
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    34
IriSP.PopcornReplacement.guid = function(prefix) {
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    35
  var str = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    36
      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
    37
      return v.toString(16);
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    38
   });
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    39
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    40
  return prefix + str;
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    41
};
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    42
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    43
IriSP.PopcornReplacement.__initApi = function() {
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    44
  IriSP.PopcornReplacement.trigger("timeupdate");
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    45
};
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    46
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    47
IriSP.PopcornReplacement.jwplayer = function(container, options) {
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    48
  IriSP.PopcornReplacement._container = container.slice(1); //eschew the '#'
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    49
  options.events = {
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    50
      onReady: IriSP.PopcornReplacement.__initApi,
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    51
      onTime: IriSP.PopcornReplacement.__timeHandler,
442
ee6594f6d00d play pause that just works (tm)
hamidouk
parents: 441
diff changeset
    52
      onPlay: IriSP.PopcornReplacement.__playHandler,
ee6594f6d00d play pause that just works (tm)
hamidouk
parents: 441
diff changeset
    53
      onPause: IriSP.PopcornReplacement.__pauseHandler,
441
99b7c5192330 fixed horrible bug involving jQuery message passing.
hamidouk
parents: 431
diff changeset
    54
      onSeek: IriSP.PopcornReplacement.__seekHandler 
99b7c5192330 fixed horrible bug involving jQuery message passing.
hamidouk
parents: 431
diff changeset
    55
      }
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    56
    
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    57
  jwplayer(IriSP.PopcornReplacement._container).setup(options);
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    58
  IriSP.PopcornReplacement.media.duration = options.duration;
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    59
  return IriSP.PopcornReplacement;
388
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
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    62
IriSP.PopcornReplacement.currentTime = function(time) {
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    63
  if (typeof(time) === "undefined") {
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    64
      return jwplayer(IriSP.PopcornReplacement._container).getPosition();            
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    65
  } else {
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    66
     var currentTime = +time;
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    67
     jwplayer( IriSP.PopcornReplacement._container ).seek( currentTime );
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    68
     return jwplayer(IriSP.PopcornReplacement._container).getPosition();            
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    69
  }
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    70
};
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    71
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    72
IriSP.PopcornReplacement.play = function() {
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    73
      IriSP.PopcornReplacement.media.paused = false;
441
99b7c5192330 fixed horrible bug involving jQuery message passing.
hamidouk
parents: 431
diff changeset
    74
      IriSP.PopcornReplacement.trigger("play");
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    75
//      IriSP.PopcornReplacement.trigger("playing");
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    76
      jwplayer( IriSP.PopcornReplacement._container ).play();
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    77
};
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    78
    
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    79
IriSP.PopcornReplacement.pause = function() {
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    80
      if ( !IriSP.PopcornReplacement.media.paused ) {
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    81
        IriSP.PopcornReplacement.media.paused = true;
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    82
        IriSP.PopcornReplacement.trigger( "pause" );
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    83
        jwplayer( IriSP.PopcornReplacement._container ).pause();
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
};
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    86
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    87
IriSP.PopcornReplacement.muted = function(val) {
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    88
  if (typeof(val) !== "undefined") {
390
9b4e5f606d72 first draft, a little rough around the edges.
hamidouk
parents: 388
diff changeset
    89
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    90
    if (jwplayer(IriSP.PopcornReplacement._container).getMute() !== val) {
390
9b4e5f606d72 first draft, a little rough around the edges.
hamidouk
parents: 388
diff changeset
    91
      if (val) {
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    92
        jwplayer(IriSP.PopcornReplacement._container).setMute(true);
448
fa9400275846 added a volume boolen in media.
hamidouk
parents: 445
diff changeset
    93
        IriSP.PopcornReplacement.media.muted = true;
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    94
      } else {
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    95
        jwplayer( IriSP.PopcornReplacement._container ).setMute(false);
448
fa9400275846 added a volume boolen in media.
hamidouk
parents: 445
diff changeset
    96
        IriSP.PopcornReplacement.media.muted = false;
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    97
      }
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
    98
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
    99
      IriSP.PopcornReplacement.trigger( "volumechange" );
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
   100
    }
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
   101
    
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
   102
    return jwplayer( IriSP.PopcornReplacement._container ).getMute();
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
   103
  } else {
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
   104
    return jwplayer( IriSP.PopcornReplacement._container ).getMute();
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
   105
  }
390
9b4e5f606d72 first draft, a little rough around the edges.
hamidouk
parents: 388
diff changeset
   106
};
9b4e5f606d72 first draft, a little rough around the edges.
hamidouk
parents: 388
diff changeset
   107
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
   108
IriSP.PopcornReplacement.mute = IriSP.PopcornReplacement.muted;
394
89a79a2c6014 WIP - working on the code function.
hamidouk
parents: 391
diff changeset
   109
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
   110
IriSP.PopcornReplacement.__codes = [];
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
   111
IriSP.PopcornReplacement.code = function(options) {
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
   112
  IriSP.PopcornReplacement.__codes.push(options);
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
   113
  return IriSP.PopcornReplacement;
390
9b4e5f606d72 first draft, a little rough around the edges.
hamidouk
parents: 388
diff changeset
   114
};
9b4e5f606d72 first draft, a little rough around the edges.
hamidouk
parents: 388
diff changeset
   115
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
   116
IriSP.PopcornReplacement.__runCode = function() {
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
   117
  var currentTime = jwplayer(IriSP.PopcornReplacement._container).getPosition();
390
9b4e5f606d72 first draft, a little rough around the edges.
hamidouk
parents: 388
diff changeset
   118
  var i = 0;
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
   119
  for(i = 0; i < IriSP.PopcornReplacement.__codes.length; i++) {
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
   120
    var c = IriSP.PopcornReplacement.__codes[i];
391
0a68395f7e12 added duration. automatically trigger timeupdate.
hamidouk
parents: 390
diff changeset
   121
    if (currentTime == c.start) {
390
9b4e5f606d72 first draft, a little rough around the edges.
hamidouk
parents: 388
diff changeset
   122
      c.onStart();
9b4e5f606d72 first draft, a little rough around the edges.
hamidouk
parents: 388
diff changeset
   123
    }
9b4e5f606d72 first draft, a little rough around the edges.
hamidouk
parents: 388
diff changeset
   124
    
391
0a68395f7e12 added duration. automatically trigger timeupdate.
hamidouk
parents: 390
diff changeset
   125
    if (currentTime == c.end) {
390
9b4e5f606d72 first draft, a little rough around the edges.
hamidouk
parents: 388
diff changeset
   126
      c.onEnd();
9b4e5f606d72 first draft, a little rough around the edges.
hamidouk
parents: 388
diff changeset
   127
    }
388
30277c1e3d46 replaced most of popcorn's functions.
hamidouk
parents: 387
diff changeset
   128
390
9b4e5f606d72 first draft, a little rough around the edges.
hamidouk
parents: 388
diff changeset
   129
  }
394
89a79a2c6014 WIP - working on the code function.
hamidouk
parents: 391
diff changeset
   130
};
391
0a68395f7e12 added duration. automatically trigger timeupdate.
hamidouk
parents: 390
diff changeset
   131
394
89a79a2c6014 WIP - working on the code function.
hamidouk
parents: 391
diff changeset
   132
/* called everytime the player updates itself 
89a79a2c6014 WIP - working on the code function.
hamidouk
parents: 391
diff changeset
   133
   (onTime event)
89a79a2c6014 WIP - working on the code function.
hamidouk
parents: 391
diff changeset
   134
 */
89a79a2c6014 WIP - working on the code function.
hamidouk
parents: 391
diff changeset
   135
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
   136
IriSP.PopcornReplacement.__timeHandler = function(event) {
417
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   137
  var pos = event.position;
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   138
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   139
  var i = 0;
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
   140
  for(i = 0; i < IriSP.PopcornReplacement.__codes.length; i++) {
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
   141
     var c = IriSP.PopcornReplacement.__codes[i];
417
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   142
     
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   143
     if (pos >= c.start && pos < c.end && 
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   144
         pos - 0.1 <= c.start) {
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   145
        c.onStart();
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   146
     }
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   147
 
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   148
     if (pos >= c.start && pos >= c.end && 
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   149
         pos - 0.1 <= c.end) {
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   150
        c.onEnd();
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   151
     }
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   152
   
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   153
  }
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   154
 
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
   155
  IriSP.PopcornReplacement.trigger("timeupdate");
390
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
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
   158
IriSP.PopcornReplacement.__seekHandler = function(event) { 
417
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   159
  var i = 0;
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
   160
  for(i = 0; i < IriSP.PopcornReplacement.__codes.length; i++) {
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
   161
     var c = IriSP.PopcornReplacement.__codes[i];
417
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   162
    
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   163
     if (event.position >= c.start && event.position < c.end) {
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   164
        c.onEnd();
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   165
     }
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   166
    
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   167
     if (typeof(event.offset) === "undefined")
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   168
       event.offset = 0;
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   169
     if (event.offset >= c.start && event.offset < c.end) {
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
     
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
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
   175
  IriSP.PopcornReplacement.trigger("timeupdate");
441
99b7c5192330 fixed horrible bug involving jQuery message passing.
hamidouk
parents: 431
diff changeset
   176
};
99b7c5192330 fixed horrible bug involving jQuery message passing.
hamidouk
parents: 431
diff changeset
   177
417
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   178
441
99b7c5192330 fixed horrible bug involving jQuery message passing.
hamidouk
parents: 431
diff changeset
   179
IriSP.PopcornReplacement.__playHandler = function(event) {
99b7c5192330 fixed horrible bug involving jQuery message passing.
hamidouk
parents: 431
diff changeset
   180
  IriSP.PopcornReplacement.media.paused = false;
442
ee6594f6d00d play pause that just works (tm)
hamidouk
parents: 441
diff changeset
   181
  IriSP.PopcornReplacement.trigger("play");
441
99b7c5192330 fixed horrible bug involving jQuery message passing.
hamidouk
parents: 431
diff changeset
   182
};
99b7c5192330 fixed horrible bug involving jQuery message passing.
hamidouk
parents: 431
diff changeset
   183
99b7c5192330 fixed horrible bug involving jQuery message passing.
hamidouk
parents: 431
diff changeset
   184
IriSP.PopcornReplacement.__pauseHandler = function(event) {
99b7c5192330 fixed horrible bug involving jQuery message passing.
hamidouk
parents: 431
diff changeset
   185
  IriSP.PopcornReplacement.media.paused = true;
442
ee6594f6d00d play pause that just works (tm)
hamidouk
parents: 441
diff changeset
   186
  IriSP.PopcornReplacement.trigger("pause");
441
99b7c5192330 fixed horrible bug involving jQuery message passing.
hamidouk
parents: 431
diff changeset
   187
};
417
bae7c50704d7 fixed code() function. The Popcorn workaround now works correctly.
hamidouk
parents: 394
diff changeset
   188
431
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
   189
IriSP.PopcornReplacement.roundTime = function() {
f9460dc1957f made our jwplayer wrapper a subobject of IriSP.
hamidouk
parents: 419
diff changeset
   190
  var currentTime = IriSP.PopcornReplacement.currentTime();
394
89a79a2c6014 WIP - working on the code function.
hamidouk
parents: 391
diff changeset
   191
  return Math.round(currentTime);
89a79a2c6014 WIP - working on the code function.
hamidouk
parents: 391
diff changeset
   192
};