问题
This seems like a simple enough question, I have some straight-forward AS3 to load a video from Youtube, using the Youtube API. That's working just fine, however I expect the default Youtube player controls to show up, and they don't seem to be. I see how to toggle them on via HTML, but I need them to be toggled on via the AS3 as I can't edit the HTML Embed or IFrame tags. Here is my code so far:
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.system.Security;
Security.allowDomain("www.youtube.com");
Security.allowInsecureDomain("www.youtube.com");
var vid_player:Object;
var my_loader:Loader = new Loader();
my_loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));
my_loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
function onLoaderInit(e:Event):void{
addChild(my_loader);
vid_player = my_loader.content;
vid_player.addEventListener("onReady", onPlayerReady);
}
function onPlayerReady(e:Event):void{
vid_player.setSize(415,234);
vid_player.loadVideoById("sq7wu4OukBE",0);
}
So this pulls it right in, but if you rollover the controls don't toggle up. I'd also like the video paused, until a user presses play, however this code above autoplays. I did come up with a setting that will show the video paused at first, however it just pulls in a large version of the video and doesn't let me size it:
loadVideoById({'videoId': 'bHQqvYy5KYo', 'startSeconds': 5, 'endSeconds': 60, 'suggestedQuality': 'large'});
adjusting suggestedQuality doesn't change dimensions just resolution. Any clarity to both questions would be greatly appreciated.
回答1:
To load the default player with controls use this url:
http://www.youtube.com/v/VIDEO_ID?version=3
Replace VIDEO_ID with the ID of your video.
Here's a good reference of all the available settings and API calls.
https://developers.google.com/youtube/flash_api_reference#Playback_controls
来源:https://stackoverflow.com/questions/18926908/as3-and-youtube-api-default-youtube-buttons