我做使用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);
}
});
}
});