This website列出了与youtube视频通信的youtube API函数。有人知道我在哪里可以找到他们的实现吗?我正在尝试找出要传递给SetVariable()以直接与youtube swf文件通信的内容。
发布于 2012-01-19 17:09:52
package
{
import flash.display.DisplayObject;
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLRequest;
public class Main extends Sprite
{
private var _loader : Loader;
private var _player : Object;
public function Main()
{
_loader = new Loader();
_loader.contentLoaderInfo.addEventListener(Event.INIT, _onLoaderInit, false, 0, true);
_loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));
}
private function _onLoaderInit(event : Event) : void
{
_player = _loader.content;
_player.addEventListener("onReady", _onPlayerReady, false, 0, true);
addChild(DisplayObject(_player));
_loader.contentLoaderInfo.removeEventListener(Event.INIT, _onLoaderInit);
_loader = null;
}
private function _onPlayerReady(event : Event) : void
{
_player.removeEventListener("onReady", _onPlayerReady);
// Once this event has been dispatched by the player, we can use
// cueVideoById, loadVideoById, cueVideoByUrl and loadVideoByUrl
// to load a particular YouTube video.
_player.setSize(640, 360);
_player.loadVideoById("D2gqThOfHu4");
}
}
}如果你想使用YouTube中的控件,你只需要替换一行:
//_loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));
//replace this line with the following
_loader.load(new URLRequest("http://www.youtube.com/v/VIDEO_ID?version=3"));
//replace VIDEO_ID with the id of the video you want to load in the previous case :"D2gqThOfHu4"
//also you can comment the following line if you don't want the video to start automatically:
_player.loadVideoById("D2gqThOfHu4");https://stackoverflow.com/questions/8921035
复制相似问题