src/js/pop.js
branchpopcorn-port
changeset 442 ee6594f6d00d
parent 441 99b7c5192330
child 445 c2eac11a9053
equal deleted inserted replaced
441:99b7c5192330 442:ee6594f6d00d
     1 /* wrapper that simulates popcorn.js because
     1 /* wrapper that simulates popcorn.js because
     2    popcorn is a bit unstable at the time */
     2    popcorn is a bit unstable at the time */
     3 
     3 
     4 IriSP.PopcornReplacement = {};
     4 IriSP.PopcornReplacement = {};
     5 IriSP.PopcornReplacement.media = { "paused": true};
     5 IriSP.PopcornReplacement.media = { 
       
     6   "paused": true
       
     7 };
     6 
     8 
     7 IriSP.PopcornReplacement.listen = function(msg, callback) {
     9 IriSP.PopcornReplacement.listen = function(msg, callback) {
     8   IriSP.jQuery(IriSP.PopcornReplacement).bind(msg, function(event, rest) { callback(rest); });
    10   IriSP.jQuery(IriSP.PopcornReplacement).bind(msg, function(event, rest) { callback(rest); });
     9 };
    11 };
    10 
    12 
    28 IriSP.PopcornReplacement.jwplayer = function(container, options) {
    30 IriSP.PopcornReplacement.jwplayer = function(container, options) {
    29   IriSP.PopcornReplacement._container = container.slice(1); //eschew the '#'
    31   IriSP.PopcornReplacement._container = container.slice(1); //eschew the '#'
    30   options.events = {
    32   options.events = {
    31       onReady: IriSP.PopcornReplacement.__initApi,
    33       onReady: IriSP.PopcornReplacement.__initApi,
    32       onTime: IriSP.PopcornReplacement.__timeHandler,
    34       onTime: IriSP.PopcornReplacement.__timeHandler,
    33   //    onPlay: IriSP.PopcornReplacement.__playHandler,
    35       onPlay: IriSP.PopcornReplacement.__playHandler,
    34   //    onPause: IriSP.PopcornReplacement.__pauseHandler,
    36       onPause: IriSP.PopcornReplacement.__pauseHandler,
    35       onSeek: IriSP.PopcornReplacement.__seekHandler 
    37       onSeek: IriSP.PopcornReplacement.__seekHandler 
    36       }
    38       }
    37     
    39     
    38   jwplayer(IriSP.PopcornReplacement._container).setup(options);
    40   jwplayer(IriSP.PopcornReplacement._container).setup(options);
    39   IriSP.PopcornReplacement.media.duration = options.duration;
    41   IriSP.PopcornReplacement.media.duration = options.duration;
   155 };
   157 };
   156 
   158 
   157 
   159 
   158 IriSP.PopcornReplacement.__playHandler = function(event) {
   160 IriSP.PopcornReplacement.__playHandler = function(event) {
   159   IriSP.PopcornReplacement.media.paused = false;
   161   IriSP.PopcornReplacement.media.paused = false;
       
   162   IriSP.PopcornReplacement.trigger("play");
   160 };
   163 };
   161 
   164 
   162 IriSP.PopcornReplacement.__pauseHandler = function(event) {
   165 IriSP.PopcornReplacement.__pauseHandler = function(event) {
   163   IriSP.PopcornReplacement.media.paused = true;
   166   IriSP.PopcornReplacement.media.paused = true;
       
   167   IriSP.PopcornReplacement.trigger("pause");
   164 };
   168 };
   165 
   169 
   166 IriSP.PopcornReplacement.roundTime = function() {
   170 IriSP.PopcornReplacement.roundTime = function() {
   167   var currentTime = IriSP.PopcornReplacement.currentTime();
   171   var currentTime = IriSP.PopcornReplacement.currentTime();
   168   return Math.round(currentTime);
   172   return Math.round(currentTime);