// the definition into Popcorn.p
var natives = Popcorn.events.all,
- reserved = [ "start", "end", "timeupdate" ],
- plugin = {},
++
+ reserved = [ "start", "end"],
+ plugin = {},
+ pluginFn,
setup;
-
-
if ( typeof definition === "object" ) {
setup = definition;
- if ( !( "timeupdate" in setup ) ) {
+ /*if ( !( "timeupdate" in setup ) ) {
setup.timeupdate = Popcorn.nop;
- }
+ }*/
- definition = function ( options ) {
-
+ pluginFn = function ( options ) {
+
- var self = this,
- fired = {
- start: 0,
- end: 0
- };
-
if ( !options ) {
return this;
}
// needs expectation
var popped = Popcorn("#video"),
- methods = "load play pause currentTime mute volume";
-
-
- stop();
+ methods = "load play pause currentTime mute volume roundTime exec",
+ expects = 22,
+ count = 0;
+ //expect(expects);
- Popcorn.plugin("subtitles", function () {
-
- var self = this;
-
- // These ensure that a popcorn instance is the value of `this` inside a plugin definition
+ function plus() {
+ console.log(count);
+ if ( ++count == expects ) {
+ start();
+ }
+ }
+
+ stop();
+
+ Popcorn.plugin("executor", function () {
- methods.split(/\s+/g).forEach(function (k,v) {
- ok( k in self, "instance has method: " + k );
- });
+ return {
+
+ start: function () {
+ var self = this;
- ok( "video" in this, "instance has `video` property" );
- ok( Object.prototype.toString.call(popped.video) === "[object HTMLVideoElement]", "video property is a HTMLVideoElement" );
+ // These ensure that a popcorn instance is the value of `this` inside a plugin definition
- ok( "data" in this, "instance has `data` property" );
- ok( Object.prototype.toString.call(popped.data) === "[object Object]", "data property is an object" );
+ methods.split(/\s+/g).forEach(function (k,v) {
+ ok( k in self, "executor instance has method: " + k );
+
+ plus();
+ });
+
+ ok( "video" in this, "executor instance has `video` property" );
+ plus();
+ ok( Object.prototype.toString.call(popped.video) === "[object HTMLVideoElement]", "video property is a HTMLVideoElement" );
+ plus();
+
+ ok( "data" in this, "executor instance has `data` property" );
+ plus();
+ ok( Object.prototype.toString.call(popped.data) === "[object Object]", "data property is an object" );
+ plus();
+
+ ok( "tracks" in this.data, "executor instance has `tracks` property" );
+ plus();
+ ok( Object.prototype.toString.call(popped.data.tracks) === "[object Array]", "executor tracks property is an array" )
+ plus();
+ },
+ end: function () {
+
+ }
+ };
+
- ok( "tracks" in this.data, "instance has `tracks` property" );
- ok( Object.prototype.toString.call(popped.data.tracks) === "[object Object]", "tracks property is an object" )
});
-
-
- // Call plugin to test scope within
- popped.subtitles();
-
-
-
- ok( "subtitles" in popped, "subtitles plugin is now available to instance" );
+
+ ok( "executor" in popped, "executor plugin is now available to instance" );
+ plus();
ok( Popcorn.registry.length === 1, "One item in the registry");
+ plus();
// These ensure that a popcorn instance is the value of `this` inside a plugin definition
methods.split(/\s+/g).forEach(function (k,v) {
- ok( k in self, "instance has method: " + k );
+ ok( k in self, "complicator instance has method: " + k );
+
+ plus();
});
- ok( "video" in this, "instance has `video` property" );
+ ok( "video" in this, "complicator instance has `video` property" );
+ plus();
ok( Object.prototype.toString.call(popped.video) === "[object HTMLVideoElement]", "video property is a HTMLVideoElement" );
+ plus();
- ok( "data" in this, "instance has `data` property" );
- ok( Object.prototype.toString.call(popped.data) === "[object Object]", "data property is an object" );
+ ok( "data" in this, "complicator instance has `data` property" );
+ plus();
+ ok( Object.prototype.toString.call(popped.data) === "[object Object]", "complicator data property is an object" );
+ plus();
- ok( "tracks" in this.data, "instance has `tracks` property" );
- ok( Object.prototype.toString.call(popped.data.tracks) === "[object Object]", "tracks property is an object" )
-
+ ok( "tracks" in this.data, " complicatorinstance has `tracks` property" );
+ plus();
+ ok( Object.prototype.toString.call(popped.data.tracks) === "[object Array]", "complicator tracks property is an array" )
- plus();
-
++ plus();
},
end: function () {