Actionscript 3 Youtube Api沙盒冲突
最近,我注意到一条沙箱违规消息,如下所示。这似乎是youtube.com和s.ytimg.com之间的跨域策略问题。我不确定,但如果有任何帮助,我们将不胜感激 *安全沙盒冲突* SecurityDomain'xhttps://www.youtube.com/apiplayer?version=3”“我试过了 访问不兼容的上下文 'xhttps://s.ytimg.com/yts/swfbin/player-vflq_SRd4/apiplayer3.swf" SecurityError:错误#2121:安全沙盒冲突: Loader.content:xhttps://www.youtube.com/apiplayer?version=3 不能 通道 xhttps://s.ytimg.com/yts/swfbin/player-vflq_SRd4/apiplayer3.swf. 这 可以通过调用Security.allowDomain来解决此问题 at flash.display::Loader/get content()at com.google.youtube.application::SwfProxy/onRequestParameters()位于 flash.events::EventDispatcher/dispatchEventFunction()位于 flash.events::EventDispatcher/dispatchEvent()位于 com.google.youtube.model::YouTubeEnvironment()位于 com.google.youtube.application::VideoApplication/createYouTubeEnvironment() 在 com.google.youtube.application::VideoApplication/onLoaderInfoInit() 源代码示例Actionscript 3 Youtube Api沙盒冲突,actionscript-3,api,youtube,youtube-api,Actionscript 3,Api,Youtube,Youtube Api,最近,我注意到一条沙箱违规消息,如下所示。这似乎是youtube.com和s.ytimg.com之间的跨域策略问题。我不确定,但如果有任何帮助,我们将不胜感激 *安全沙盒冲突* SecurityDomain'xhttps://www.youtube.com/apiplayer?version=3”“我试过了 访问不兼容的上下文 'xhttps://s.ytimg.com/yts/swfbin/player-vflq_SRd4/apiplayer3.swf" SecurityError:错误#21
我总是被Flash Builder和Flashdevelop控制台中的信息信息淹没,这些信息看起来就像是您错误的第一行。这是由YouTube糟糕的crossdomain.xml和Flash不合理的跨域安全性造成的,但并不影响编译。最近,它们变成了停止编译的错误消息。它们与您的相同,也显示了错误跟踪线。我没有更改任何相关代码或更改Flash版本/设置,因此我怀疑这是YouTube更改的内容。我注意到我的错误在我认为应该是http的时候提到了https。谢谢你好心的先生。我想确定的是,我没有错过一些新的东西或某种类型的更新。几天前开始的。
// 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("youtube.com");
Security.allowDomain("s.ytimg.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 {
addChild(loader);
loader.content.addEventListener("onReady", onPlayerReady);
loader.content.addEventListener("onError", onPlayerError);
loader.content.addEventListener("onStateChange", onPlayerStateChange);
loader.content.addEventListener("onPlaybackQualityChange",
onVideoPlaybackQualityChange);
}
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;
// Set appropriate player dimensions for your application
player.setSize(480, 360);
player.loadVideoById("M7lc1UVf-VE")
}
function onPlayerError(event:Event):void {
// Event.data contains the event parameter, which is the error code
trace("player error:", Object(event).data);
}
function onPlayerStateChange(event:Event):void {
// Event.data contains the event parameter, which is the new player state
trace("player state:", Object(event).data);
}
function onVideoPlaybackQualityChange(event:Event):void {
// Event.data contains the event parameter, which is the new video quality
trace("video quality:", Object(event).data);
}