Absolutely wonderful that Google has finally released an AS3 version of their chromeless player for use in Flex/AS3 projects. No more weird proxy hacks!!!
I’ve thrown together a quick example and have posted the code below. Really simple stuff to set up and use. Google seems to be more and more friendly to the Flash world lately. There are at least two major projects I’m going to implement this in as soon as I get the time to do so. Very nice- I’m quite pleased!
View the Example:
[SWF]https://inflagrantedelicto.memoryspiral.com/wp-content/uploads/2009/10/YouTubeAS3.swf, 480, 500[/SWF]
References:
The ActionScript 3 YouTube Chromeless Player is Now Live
YouTube ActionScript 3.0 Player API Reference
Download the Example:
YouTubeAS3.fxp
View Code for Flash Builder 4:
Hi,
I’m looking for a way to integrate a YouTube movie into my Flash application (being able, of course to load, play, pause, get events etc).
I’d appreciate any help on this issue,
Thanks,
EZ
Hi,
very useful…
I try to integrate your code in a Flash Application with no success :-(
An error occured :
*** Security Sandbox Violation ***
SecurityDomain ‘http://inflagrantedelicto.memoryspiral.com/2009/10/google-finally-releases-as3-player-for-youtube/’ tried to access incompatible context…
Any idea ?
@EZ – The API Reference Google provides details all that and more. I’ve integrated this fully into two projects and it works very nicely:
http://blogs.adobe.com/educationleaders/2009/10/youtube_and_flash_platform_as3.html
@Pascal – It’s strange that you would get a sandbox error specifying this domain – are you trying to load something from here? You can send me the files, if you like. Or detail the relevant code in comments, here.
@Joseph :
Your exemple trigger a sandbox error too ;-)
*** Security Sandbox Violation ***
SecurityDomain ‘http://www.youtube.com/apiplayer?version=3’ tried to access incompatible context ‘http://inflagrantedelicto.memoryspiral.com/2009/10/google-finally-releases-as3-player-for-youtube/’
I fixed the problem with including this :
Security.allowInsecureDomain(“*”);
Security.allowDomain(“*”);
“Security Sandbox Violation” is more of a warning message than an error. If I recall, this is expected behavior when running against YouTube stuff even in the AS2 player. Those security settings may remove the message locally, but when on a webserver it shouldn’t matter.
Also keep in mind that this example was whipped together the night Google released the API and I must have spent all of 15 minutes on the example ;)
@Joseph,
I too got the “Security Sandbox Violation” error…
I’d really appreciate a simple CS4 file, if it is not too much trouble…
Thanks a lot,
EZ
Pingback: YouTube AS3 Example Using Flash Professional | In Flagrante Delicto!
@EZ Sure, check it out: http://inflagrantedelicto.memoryspiral.com/2009/10/youtube-as3-example-using-flash-professional/
Also modified Flex examples to include Security bits.
@Joseph
Working great!
Thanks a lot.
One more question:
I’m trying to sync YouTube’s movie with events in my game.
When I use the player.getCurrentTime() method I notice that it gets updated only every ~0.1 sec (which is a low rate).
Does anyone knows if it is possible to get updates at a higher rate?
Thanks,
EZ
I want to tell you that you are a good writer. Awsome articles
I appreciate, lead to I discovered exactly what I used to be having a look for. You’ve ended my 4 day lengthy hunt! God Bless you man. Have a great day. Bye
nice article….awasome…… :)