Actionscript 3 YouTube AS3 API中的某些函数返回错误的值
我现在正在处理某个AS3应用程序。代码与文档中的AS3示例非常相似:Actionscript 3 YouTube AS3 API中的某些函数返回错误的值,actionscript-3,api,youtube,Actionscript 3,Api,Youtube,我现在正在处理某个AS3应用程序。代码与文档中的AS3示例非常相似: // The player SWF file on www.youtube.com needs to communicate with your host // SWF file. Your code must call Security.allowDomain() to allow this // communication. Security.allowDomain("www.youtube.com"); // This
// The player SWF file on www.youtube.com needs to communicate with your host
// SWF file. Your code must call Security.allowDomain() to allow this
// communication.
Security.allowDomain("www.youtube.com");
// This will hold the API player instance once it is initialized.;
var player:Object;
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));
function onLoaderInit(event:Event):void
{
stage.addChild(loader);
loader.content.addEventListener("onReady", onPlayerReady);
}
function onPlayerReady(event:Event):void
{
// Event.data contains the event parameter, which is the Player API ID
trace("player ready:", Object(event).data);
// Once this event has been dispatched by the player, we can use
// cueVideoById, loadVideoById, cueVideoByUrl and loadVideoByUrl
// to load a particular YouTube video.
player = loader.content;
player.loadVideoById("nJ3MSCLBpaM");
// Set appropriate player dimensions for your application;
setPlayerSize();
stage.addEventListener(Event.RESIZE, updatePlayerSize);
}
function setPlayerSize():void
{
player.y = 0;
player.x = 0;
player.setSize(stage.stageWidth, stage.stageHeight);
}
function getVideoBytesTotal()
{
return player.getVideoBytesTotal();
}
function getVideoBytesLoaded()
{
return player.getVideoBytesLoaded();
}
function getVideoStartBytes()
{
return player.getVideoStartBytes();
}
出于某种原因,当我在视频加载后(播放时)调用最后三个函数中的一个时,我从所有函数中得到的都是0。为什么会这样?这些函数已被弃用。 使用
相反。我面临着同样的问题!!!我注意到这只发生在firefox中。Chrome很好用。事实上我用的是Chrome,但它不起作用这个测试对你有用吗?这是在使用JSAPI。我在AS工作。
player.getVideoLoadedFraction()