},
listen: function ( type, fn ) {
- var self = this, hasEvents = true;
+ var self = this, hasEvents = true, ns = '';
if ( !this.data.events[type] ) {
this.data.events[type] = {};
setup = definition;
-
+ if ( !( "timeupdate" in setup ) ) {
+ setup.timeupdate = Popcorn.nop;
+ }
+
definition = function ( options ) {
var self = this;
options.end = this.duration();
}
- if ( !( "timeupdate" in options ) ) {
- options.timeupdate = Popcorn.nop;
- }
-
// If a _setup was declared, then call it before
// the events commence
}
// Plugin timeline handler
- this.video.addEventListener( "timeupdate", function( event ) {
+ this.listen( "timeupdate", function( event ) {
if ( ~~self.currentTime() === options.start ||
setup.end.call(self, event, options);
}
- }, false);
-
-
- // Future support plugin definitions for all of the native events
- Popcorn.forEach( options, function ( key ) {
-
- console.log(key);
});
-
-
+ // Future support for plugin event definitions
+ // for all of the native events
+ Popcorn.forEach( setup, function ( callback, type ) {
+
+ if ( reserved.indexOf(type) === -1 ) {
+
+ this.listen( type, callback );
+ }
+
+ }, this);
return this;
};
QUnit.reset();
var p = Popcorn("#video"),
- completed = [],
- eventtest = "loadstart progress suspend emptied stalled play pause " +
- "loadedmetadata loadeddata waiting playing canplay canplaythrough " +
- "seeking seeked timeupdate ended ratechange durationchange volumechange",
- events = eventtest.split(/\s+/g);
+ completed = [];
- var expects = events.length,
+ var expects = Setup.events.length,
count = 0;
expect(expects);
stop();
- events.forEach(function ( name ) {
+ Setup.events.forEach(function ( name ) {
p.listen( name, function (event) {
if ( completed.indexOf(name) === -1 ) {
});
});
- events.forEach(function ( name ) {
+ Setup.events.forEach(function ( name ) {
p.trigger( name );
});
QUnit.reset();
var p = Popcorn("#video"),
- completed = [],
- eventtest = "loadstart progress suspend emptied stalled play pause " +
- "loadedmetadata loadeddata waiting playing canplay canplaythrough " +
- "seeking seeked timeupdate ended ratechange durationchange volumechange",
- events = eventtest.split(/\s+/g);
+ completed = [];
var expects = 11,
stop();
- events.forEach(function ( name ) {
+ Setup.events.forEach(function ( name ) {
p.listen( name, function (event) {
if ( completed.indexOf(name) === -1 ) {
},
end: function () {
- start();
+ //start();
},
timeupdate: function () {
end: 2
});
+
+ Popcorn.plugin("breaker", {
+
+ start: function () {
+ ok(true, "plugin:breaker started");
+ },
+ end: function () {
+ ok(true, "plugin:ended started");
+ start();
+ }
+ });
+
+
+
+ popped.currentTime(0);
+
+ popped.breaker({
+ start: 1,
+ end: 2
+ });
+});
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+test("Popcorn Plugin Extended Events", function () {
+
+ //QUnit.reset();
+
+ // needs expectation
+
+ var popped = Popcorn("#video"),
+ expects = 11,
+ count = 0;
+
+ //expect(expects);
+ // not in full use
+ function plus(){
+ if ( ++count == expects ) start();
+ }
+
+ stop();
+
+
+ Popcorn.plugin("extendedEvents", (function () {
+
+
+ var pluginObj = {
+
+ start: function() {
+
+ },
+ end: function() {
+
+ }
+ };
+
+ $.each( Setup.events, function ( k, type ) {
+
+ pluginObj[type] = function (event, opts) {
+ ok( true, type + " fired!" );
+
+ plus();
+ };
+
+ });
+
+ return pluginObj;
+
+ })());
+
-});
\ No newline at end of file
+
+
+ popped.extendedEvents({
+
+ start: 20,
+ end: 21
+
+ });
+
+
+ popped.currentTime(19).play();
+
+
+});
+
+/*
+module("Popcorn Video Object")
+test("wait()", function () {
+
+ //QUnit.reset();
+
+ // needs expectation
+
+ var popped = Popcorn("#video"),
+ startat = +new Date();
+
+
+
+
+ popped.play().wait(2).exec(function () {
+
+ console.log( +new Date() - startat );
+
+ ok(true)
+
+ }).pause();
+
+
+});
+*/
\ No newline at end of file