--- a/src/js/pop.js Fri Dec 02 15:41:53 2011 +0100
+++ b/src/js/pop.js Fri Dec 02 15:42:06 2011 +0100
@@ -2,14 +2,14 @@
popcorn is a bit unstable at the time */
Popcorn = {};
-Popcorn.media = {};
+Popcorn.media = { "paused": true};
Popcorn.listen = function(msg, callback) {
- IriSP.jQuery(Popcorn).bind(msg, callback);
+ IriSP.jQuery(Popcorn).bind(msg, function(event, rest) { callback(rest); });
};
Popcorn.trigger = function(msg, params) {
- IriSP.jQuery(msg, params);
+ IriSP.jQuery(Popcorn).trigger(msg, params);
};
Popcorn.guid = function(prefix) {
@@ -29,8 +29,28 @@
Popcorn._container = container.slice(1); //eschew the '#'
options.events = {
onReady: Popcorn.__initApi,
- onTime: Popcorn.__timeHandler
- };
+ onTime: Popcorn.__timeHandler,
+ onSeek: function(event) {
+ var i = 0;
+ console.log("old: %d, new: %d", event.position, event.offset);
+ for(i = 0; i < Popcorn.__codes.length; i++) {
+ var c = Popcorn.__codes[i];
+
+ if (event.position >= c.start && event.position < c.end) {
+ c.onEnd();
+ }
+
+ if (typeof(event.offset) === "undefined")
+ event.offset = 0;
+ if (event.offset >= c.start && event.offset < c.end) {
+ c.onStart();
+ }
+
+ }
+
+ Popcorn.trigger("timeupdate");
+ }
+ }
jwplayer(Popcorn._container).setup(options);
Popcorn.media.duration = options.duration;
@@ -42,8 +62,6 @@
return jwplayer(Popcorn._container).getPosition();
} else {
var currentTime = +time;
- Popcorn.trigger("seeked");
- Popcorn.trigger("timeupdate");
jwplayer( Popcorn._container ).seek( currentTime );
return jwplayer(Popcorn._container).getPosition();
}
@@ -51,8 +69,8 @@
Popcorn.play = function() {
Popcorn.media.paused = false;
- Popcorn.trigger("play");
- Popcorn.trigger("playing");
+// Popcorn.trigger("play");
+// Popcorn.trigger("playing");
jwplayer( Popcorn._container ).play();
};
@@ -74,7 +92,7 @@
jwplayer( Popcorn._container ).setMute(false);
}
- media.dispatchEvent( "volumechange" );
+ Popcorn.trigger( "volumechange" );
}
return jwplayer( Popcorn._container ).getMute();
@@ -83,17 +101,15 @@
}
};
+Popcorn.mute = Popcorn.muted;
+
Popcorn.__codes = [];
Popcorn.code = function(options) {
Popcorn.__codes.push(options);
return Popcorn;
};
-/* called everytime the player updates itself
- (onTime event)
- */
-
-Popcorn.__timeHandler = function() {
+Popcorn.__runCode = function() {
var currentTime = jwplayer(Popcorn._container).getPosition();
var i = 0;
for(i = 0; i < Popcorn.__codes.length; i++) {
@@ -107,6 +123,17 @@
}
}
+};
+/* called everytime the player updates itself
+ (onTime event)
+ */
+
+Popcorn.__timeHandler = function() {
Popcorn.trigger("timeupdate");
};
+
+Popcorn.roundTime = function() {
+ var currentTime = Popcorn.currentTime();
+ return Math.round(currentTime);
+};