gpt4 book ai didi

flash - Youtube API 函数

转载 作者:行者123 更新时间:2023-12-02 02:19:36 25 4
gpt4 key购买 nike

This website列出了与 youtube 视频通信的 youtube API 函数。有人知道我在哪里可以找到他们的实现吗?我试图弄清楚要传递给 SetVariable() 的内容以直接与 youtube swf 文件通信。

最佳答案

 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");

关于flash - Youtube API 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8921035/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com