mirror of
https://github.com/videojs/video.js.git
synced 2025-01-27 11:22:06 +02:00
Added code to pass plugins tests
This commit is contained in:
parent
6f2597cc8d
commit
cb77fb337f
@ -13,6 +13,7 @@ goog.require('vjs.Html5');
|
||||
goog.require('vjs.Flash');
|
||||
goog.require('vjs.TextTrack');
|
||||
goog.require('vjs.autoSetup');
|
||||
goog.require('vjs.plugin');
|
||||
|
||||
/**
|
||||
* vjs (internal only) = videojs = _V_ (external only)
|
||||
|
@ -51,10 +51,10 @@ vjs.obj.hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
* @param {Function} fn Function to be called on each property.
|
||||
* @this {*}
|
||||
*/
|
||||
vjs.obj.each = function(obj, fn){
|
||||
vjs.obj.each = function(obj, fn, context){
|
||||
for (var key in obj) {
|
||||
if (vjs.obj.hasOwnProperty.call(obj, key)) {
|
||||
fn.call(this, key, obj[key]);
|
||||
fn.call(context || this, key, obj[key]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -55,6 +55,13 @@ vjs.Player = function(tag, options, ready){
|
||||
|
||||
// Make player easily findable by ID
|
||||
vjs.players[this.id_] = this;
|
||||
|
||||
var player = this;
|
||||
if (options['plugins']) {
|
||||
vjs.obj.each(options['plugins'], function(key, val){
|
||||
player[key](val);
|
||||
});
|
||||
}
|
||||
};
|
||||
goog.inherits(vjs.Player, vjs.Component);
|
||||
|
||||
|
7
src/js/plugins.js
Normal file
7
src/js/plugins.js
Normal file
@ -0,0 +1,7 @@
|
||||
goog.provide('vjs.plugin');
|
||||
|
||||
vjs.plugins = {};
|
||||
|
||||
vjs.plugin = function(name, init){
|
||||
vjs.Player.prototype[name] = init;
|
||||
};
|
@ -24,7 +24,7 @@
|
||||
'test/unit/mediafaker.js',
|
||||
'test/unit/player.js',
|
||||
'test/unit/core.js',
|
||||
'test/unit/media.html5.js'
|
||||
'test/unit/media.html5.js',
|
||||
'test/unit/plugins.js'
|
||||
];
|
||||
var compiledTests = "build/files/test.minified.video.js";
|
||||
|
@ -24,7 +24,7 @@ test('Plugin should get initialized and receive options', function(){
|
||||
});
|
||||
|
||||
test('Plugin should have the option of being initilized outside of player init', function(){
|
||||
expect(3)
|
||||
expect(3);
|
||||
|
||||
vjs.plugin('myPlugin3', function(options){
|
||||
ok(true, 'Plugin initialized after player init');
|
||||
@ -43,10 +43,10 @@ test('Plugin should have the option of being initilized outside of player init',
|
||||
});
|
||||
|
||||
test('Plugin should be able to add a UI component', function(){
|
||||
expect(2)
|
||||
expect(2);
|
||||
|
||||
vjs.plugin('myPlugin4', function(options){
|
||||
ok(instanceof this === 'vjs.Player', 'Plugin executed in player scope by default');
|
||||
ok((this instanceof vjs.Player), 'Plugin executed in player scope by default');
|
||||
this.addChild('component');
|
||||
});
|
||||
|
||||
@ -56,7 +56,7 @@ test('Plugin should be able to add a UI component', function(){
|
||||
});
|
||||
|
||||
var comp = player.getChild('component');
|
||||
ok(comp, 'Plugin added a component to the player'
|
||||
ok(comp, 'Plugin added a component to the player');
|
||||
|
||||
player.dispose();
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user