我正在制作一个基于 Youtube AS3 API 的网络应用程序。一切都很顺利,现在突然间我所有的播放器功能都停止了工作。除了“onYouTubePlayerAPIReady”之外,没有任何事件被调用。我现在有按钮来控制视频的音量给我错误“player.getVolume() 不是函数”。我能够成功加载视频并播放它,但仅此而已。
var h = ($("#ytplayer").width()*(9/16));
player = new YT.Player('ytplayer', {
height: h,
videoId: currentlyPlaying,
playerVars: {
wmode: 'opaque',
autoplay: '1',
vq: 'small',
controls: '0',
iv_load_policy: '3',
rel: '0'
},
events: {
'onStateChange': onPlayerStateChange
}
});
makeControlsLive();
function makeControlsLive(){
/*Make controls live*/
logThis("Making ocntrols live now...");
$("#vol_up").click( function(){
if(player){
var currentVol = player.getVolume();
if((currentVol+10) <= 100){
player.setVolume(currentVol+10);
$("#vol_value").text((currentVol+10)+"%");
$("#vol_mute").text(" mute ");
}
}
});
$("#vol_down").click( function(){
if(player){
var currentVol = player.getVolume();
if((currentVol-10) >= 0){
player.setVolume(currentVol-10);
$("#vol_value").text((currentVol-10)+"%");
}
}
});
$("#vol_mute").click( function(){
if(player){
if(player.isMuted()){
$("#vol_mute").text(" mute ");
player.unMute();
}
else{
$("#vol_mute").text(" unmute ");
player.mute();
}
}
});
}
function onPlayerStateChange(newState) {
alert(player.getPlayerState());
}
有人遇到过类似的问题吗?youtube服务器是否有可能存在错误?