YouTube Flash API 中的错误代码 0 是什么意思?尝试使用 API 播放某些视频时会发生这种情况。API 参考中解释了其他错误代码,但没有错误代码 0。
如何让 YouTube 播放器播放所有视频,就像在YouTube 播放器演示中一样?
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";
}
}
}