src/js/pop.js
branchno-popcorn
changeset 391 0a68395f7e12
parent 390 9b4e5f606d72
child 394 89a79a2c6014
equal deleted inserted replaced
390:9b4e5f606d72 391:0a68395f7e12
    27 
    27 
    28 Popcorn.jwplayer = function(container, options) {
    28 Popcorn.jwplayer = function(container, options) {
    29   Popcorn._container = container.slice(1); //eschew the '#'
    29   Popcorn._container = container.slice(1); //eschew the '#'
    30   options.events = {
    30   options.events = {
    31       onReady: Popcorn.__initApi,
    31       onReady: Popcorn.__initApi,
    32       onTime: Popcorn.__timehandler 
    32       onTime: Popcorn.__timeHandler 
    33     };
    33     };
    34     
    34     
    35   jwplayer(Popcorn._container).setup(options);
    35   jwplayer(Popcorn._container).setup(options);
       
    36   Popcorn.media.duration = options.duration;
    36   return Popcorn;
    37   return Popcorn;
    37 };
    38 };
    38 
    39 
    39 Popcorn.currentTime = function(time) {
    40 Popcorn.currentTime = function(time) {
    40   if (typeof(time) === "undefined") {
    41   if (typeof(time) === "undefined") {
    90 
    91 
    91 /* called everytime the player updates itself 
    92 /* called everytime the player updates itself 
    92    (onTime event)
    93    (onTime event)
    93  */
    94  */
    94 
    95 
    95 Popcorn.__timehandler = function() {
    96 Popcorn.__timeHandler = function() {
    96   var currentTime = jwplayer(Popcorn._container).getPosition();
    97   var currentTime = jwplayer(Popcorn._container).getPosition();
    97   var i = 0;
    98   var i = 0;
    98   for(i = 0; i < Popcorn.__codes.length; i++) {
    99   for(i = 0; i < Popcorn.__codes.length; i++) {
    99     var c = Popcorn.__codes[i];
   100     var c = Popcorn.__codes[i];
   100     if (currentTime <= c.start && currentTime + 0.1 >= c.start) {
   101     if (currentTime == c.start) {
   101       c.onStart();
   102       c.onStart();
   102     }
   103     }
   103     
   104     
   104     if (currentTime <= c.end && currentTime + 0.1 >= c.end) {
   105     if (currentTime == c.end) {
   105       c.onEnd();
   106       c.onEnd();
   106     }
   107     }
   107 
   108 
   108   }
   109   }
       
   110 
       
   111   Popcorn.trigger("timeupdate");
   109 };
   112 };