我做使用JQuery和YouTube JS API视频播放器,我VARIOS控制YouTube播放器对象的方法,例如:错误:调用NPObject上的方法时出错!与YouTube JSAPI
setVolumen: function (value) {
if (value < 0 || value > 100) {
this.throwError("Volumen inválido: "+ value);
return;
}
this.volume = value;
this.elements.player.each(function() {
if (typeof this.setVolume != "undefined") {
this.setVolume(value);
}
});
},
“this.elements.player”是yt播放器对象的jquery选择器。我从player-controll实例调用一个setVolume方法并工作。例如:
// This is inside a method of controller class
// and self is a reference to "this" in method context
this.celements.volume.slider({
max: 100,
value: 100,
change: function (event, obj) {
self.setVolumen(obj.value);
}
});
如果我移动滑块元素,这个工程没有问题,买我打电话从jQuery选择的方法:
$( '#播放列表')UplayList( 'setVolumen',80) ;
this thrown“错误:在NPObject上调用方法时出错!”
该对象存在,并且setVolume不是未定义的。我不明白。
jQuery的一个有:
$.fn.extend({
UplayList: function (options) {
this.each(function () {
if ($(this).data('uplaylistId')) {
var instance = $.playList.instances[$(this).data('uplaylistId')];
instance[options].apply(instance, Array.prototype.slice.call(arguments, 1));
} else {
var instance = new $.playList(this, options);
var id = instance.elements.player.attr('id');
$(this).data('uplaylistId',id);
}
});
}
});