views:

34

answers:

2

I'm trying to use the Youtube Chromeless Player (the new AS3 version) in a Flex 4-based project. I'm using the examples provided by Google, but I'm not having any luck. The player loads, but it can't be interacted with. I'm receiving repeated security errors just from mousing over the player:

*** 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'

I've tried adding Security.allowDomain("www.youtube.com"); to my creationComplete handler before loading the player, and still receive the same errors.

I've also tried using a SWFLoader like so:

<?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>

I've been at this for a few hours now, and haven't had any success. I also can't seem to find any working examples online. Is this new player just not compatible with Flex 4?

A: 

Can you try accessing your SWF via HTTP from some web server? One running locally might do the trick, or obviously a remote one. There can be security context issues (with the YouTube Player APIs and many other external SWFs as well) when your SWF is accessed via a file:// URI scheme.

jeffposnick
I have tried loading the SWF via HTTP and still receive the same errors. However, I did manage to get the player working like I wanted it to. (Details above.)
joshbuhler
A: 

I think the error comes from YouTube , see my answer here: http://stackoverflow.com/questions/3785124/how-to-avoid-security-errors-when-using-the-youtube-as3-player-api/3785622#3785622

PatrickS
Thinking you're right here - their cross-domain policy file seems off. Luckily all I'm receiving are multiple warnings so the app is at least working. (For the time being.)
joshbuhler