錯誤代碼0在YouTube Flash API中的含義是什麼?它在嘗試使用API播放一些視頻時發生。其他錯誤代碼在API Reference解釋,但不是錯誤代碼0YouTube API播放器不播放某些視頻
如何使YouTube播放器播放所有視頻,就像它在YouTube Player Demo?
FLA和SWF文件:https://s3.amazonaws.com/YouTubeAPIError0/YouTubeAPIError0.zip
package {
import flash.system.Security;
import flash.display.MovieClip;
import flash.display.Loader;
import flash.events.Event;
import flash.net.URLRequest;
import fl.data.DataProvider;
import fl.controls.ComboBox;
import fl.controls.TextArea;
public class YouTubeAS3 extends MovieClip {
public var VidHolder:MovieClip;
public var VidSelection:ComboBox;
public var traceArea:TextArea;
private var player:Object;
private var loader:Loader;
private var vidCollection:DataProvider;
public function YouTubeAS3():void {
Security.allowInsecureDomain("*");
Security.allowDomain("*");
vidCollection = new DataProvider();
vidCollection.addItem({data:"eDdI7GhZSQA", label:"Video 1"});
vidCollection.addItem({data:"S09F5MejfBE", label:"Video 2"});
vidCollection.addItem({data:"QUwxKWT6m7U", label:"Video 3"});
vidCollection.addItem({data:"TAbnQZZ6QXc", label:"Video 4"});
vidCollection.addItem({data:"QH2-TGUlwu4", label:"Errorless Video"});
VidSelection.dataProvider = vidCollection;
VidSelection.addEventListener(Event.CHANGE, cueVideo);
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));
}
private function onLoaderInit(event:Event):void {
VidHolder.addChild(loader);
loader.content.addEventListener("onReady", onPlayerReady);
loader.content.addEventListener("onError", onPlayerError);
loader.content.addEventListener("onStateChange", onPlayerStateChange);
loader.content.addEventListener("onPlaybackQualityChange", onVideoPlaybackQualityChange);
}
private function onPlayerReady(event:Event):void {
traceArea.text += "player ready: " + Object(event).data + "\r";
player = loader.content;
player.setSize(480, 360);
VidSelection.selectedIndex = 0;
VidSelection.dispatchEvent(new Event(Event.CHANGE));
}
private function cueVideo(event:Event):void {
traceArea.text += "switch to: " + event.target.selectedItem.label + "\r";
player.cueVideoById(event.target.selectedItem.data);
}
private function onPlayerError(event:Event):void {
traceArea.text += "player error: " + Object(event).data + "\r";
}
private function onPlayerStateChange(event:Event):void {
traceArea.text += "player state: " + Object(event).data + "\r";
}
private function onVideoPlaybackQualityChange(event:Event):void {
traceArea.text += "video quality: " + Object(event).data + "\r";
}
}
}
我的猜測是,這是在YouTube播放器中的錯誤,在錯誤不是在分派事件之前正確初始化。不幸的是,我不能重複你所看到的 - 當我運行它時,你提供的示例代碼對我來說工作得很好,沒有任何錯誤。 –
@joshbuhler什麼讓你的機器特別?我甚至多次通過美國/加拿大代理服務器連接,前4個視頻仍然存在錯誤0。 – Pleo
是否有人用上面的代碼獲得這個奇怪的錯誤? – Pleo