What does error code 0 mean in YouTube Flash API? It occurs when trying to play some videos with the API. Other error codes are explained in the API Reference, but not error code 0.
How do I make the YouTube player play all videos, just like it does on YouTube Player Demo?
FLA and SWF files: 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";
}
}
}