这似乎是一个再简单不过的问题,我有一些直接的AS3加载从Youtube视频,使用YouTube API。这工作得很好,但我希望的默认YouTube播放器控件显示出来,而且他们似乎并不如此。我看到如何通过HTML切换他们,但我需要他们通过AS3被触发作为我不能编辑HTML嵌入或iframe标签。这是我的code到目前为止:
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);
}
所以这个拉是正确的,但如果你翻转的控制不会切换了。我还喜欢在视频暂停,直到用户presses发挥,然而,这code以上autoplays。我没有拿出,将显示在视频暂停在第一个设置,但它只是拉在一个大版本的视频,并没有让我它的大小:
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'});
调整suggestedQuality不改变尺寸公正的解决。任何清晰度,这两个问题将是极大的AP preciated。
adjusting suggestedQuality doesn't change dimensions just resolution. Any clarity to both questions would be greatly appreciated.
推荐答案
要加载默认的播放器控件使用这个网址:
To load the default player with controls use this url:
http://www.youtube.com/v/VIDEO_ID?version=3
替换VIDEO_ID与视频的ID。
Replace VIDEO_ID with the ID of your video.
下面是所有可用的设置和API调用一个很好的参考。
Here's a good reference of all the available settings and API calls.
https://developers.google.com/youtube/flash_api_reference#Playback_controls
相关推荐
最新文章