1

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?

Wade Mueller
  • 6,059
  • 17
  • 19
Josh Buhler
  • 26,878
  • 9
  • 29
  • 45
  • While I'm still receiving the security errors, I have managed to solve the problem of not interacting with the player - turns out that I was sending the wrong parameters to one of the player methods. I'll leave the question open until I figure out how to resolve the security errors though. – Josh Buhler Jul 13 '10 at 15:42

2 Answers2

0

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.

Jeff Posnick
  • 53,580
  • 14
  • 141
  • 167
  • 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.) – Josh Buhler Jul 13 '10 at 15:41
  • how did you manage to get the mouseEvents working? I cannot see any details above ;-) I'm having the same problem right now...would love to have a solution. – iddqd Mar 03 '11 at 21:35
0

I think the error comes from YouTube , see my answer here: How to avoid Security Errors when using the Youtube AS3 Player API

Community
  • 1
  • 1
PatrickS
  • 9,539
  • 2
  • 27
  • 31
  • 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.) – Josh Buhler Oct 06 '10 at 17:06