使用Youtube AS3 Chromeless Player的安全错误

时间:2010-07-06 19:49:42

标签: flex youtube flex4

我正在尝试在基于Flex 4的项目中使用Youtube Chromeless Player(新的AS3版本)。我正在使用谷歌的examples provided,但我没有运气。播放器加载,但无法与之交互。我只是因为鼠标悬停在播放器上而收到重复的安全错误:

*** Security Sandbox Violation ***
SecurityDomain 'http://www.youtube.com/apiplayer?version=3' tried to access
incompatible context 'file:///Users/jbuhler/Sites/YoutubeTests/bin-debug/YoutubeTest.html'

我尝试过添加Security.allowDomain(“www.youtube.com”);在加载播放器之前,我的creationComplete处理程序仍然收到相同的错误。

我也试过像这样使用SWFLoader:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark" 
           xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
           initialize="onInit()">
<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>

<fx:Script>
    <![CDATA[

        private function onInit ():void
        {
            Security.allowDomain("www.youtube.com");
        }
    ]]>
</fx:Script>
<mx:SWFLoader source="http://www.youtube.com/apiplayer?version=3" />
</s:Application>

我已经在这里待了几个小时,并没有取得任何成功。我似乎也无法在网上找到任何工作示例。这个新播放器是否与Flex 4不兼容?

2 个答案:

答案 0 :(得分:0)

您可以尝试通过HTTP从某个Web服务器访问SWF吗?一个在本地运行的人可能会做这个技巧,或者显然是一个远程技当您通过file:// URI方案访问SWF时,可能存在安全上下文问题(使用YouTube播放器API和许多其他外部SWF)。

答案 1 :(得分:0)

我认为错误来自YouTube,请在此处查看我的回答: How to avoid Security Errors when using the Youtube AS3 Player API

相关问题