Home  >  

Introducing TubeLoc: AS3/Flex YouTube Player API

Author photo
| | Comments (9)
AddThis Social Bookmark Button

Almost a year ago the YouTube APIs and Tools team released the YouTube Player API. The SWF that exposed the player functionality was and still is written in ActionScript 2. To make this easier to use in ActionScript 3, there have been a few projects along the way. They have either seemed to be a little bit too complicated, or have ignored Flex, Flash, the chromeless player, or the full-chrome player.

We all would like a native ActionScript 3 Player API. So I figured that If I wrote a AS3/Flex proxy library for the AS2 YouTube Player API, surely then and only then would the AS3 native player come out. Of course, right? :) We'll see. In the meantime we have TubeLoc.

Here are the details:

  • Easily use the YouTube Player API in your Flex/AS3 projects
  • Includes a Flex component and a Sprite-based ActionScript 3 class
  • Can use YouTube's chromeless player or full-chrome player
  • Uses LocalConnection

  • ActionScript 2 SWF built using MTASC


A couple members of the YouTube team helped out a lot with feedback and review, so a big thanks goes out to Jeff and Phil. To get more information you can check out the YouTube API announcement, read the article on how to use the library, and of course visit the Google Code project page. There is still room for improvement, so feel free to report any issues on the Google Code project.

Read more from Ben Longoria. Ben Longoria's Atom feed enefekt on Twitter

Comments

9 Comments

Hi Ben,
Can you please email me at admin[-at-]thedesktube[-dot-]com.
Thanks,
Damon

Hi Ben,

Do you know any more about why it's not possible to have more than one instance of the player on the stage at once? Getting round this would enable me to redo http://passingby.tv/ without having to pipe the videos through my own server.

james

Ben Longoria said:

Hello James,

From what I understand, there are some low-level issues with the YouTube player itself. This may have been fixed, or fixed with some work-arounds.

I'm trying to find the time to look into this and see if I can get it working. Follow the Google Code project for any updates.

Elisheva said:

Playing in more than one location inside a flex app

I want to use TubeLoc to play youtube videos from my flex-app. How ever, I have several locations (mxml files) where I need to place the
tag.

It plays from the first spot the user reaches, but not from the following ones. I see that there is a new localconnection created for each , still I get the error of "already connected" when the line number 159 in MovieSprite.as is run:

receivingConnection.connect(as3Id);

Is there a way to overcome this ?.

Thanks

Elisheva


Leslie Bertels said:

Hi.

I'm using tubeloc in my AIR app to show the chromeless youtube player. It works but a huge number of security sandbox violation errors are thrown constantly!
Any ideas?
I've tried to add the allowdomain("*") but air apps do not allow to do this :(

here the error:

*** Security Sandbox Violation ***
SecurityDomain 'http://www.youtube.com/swf/cl.swf?eurl=app%3A/as2_tubeloc.swf%3Fas3Id%3Das3Id_12415076817010%26as2Id%3Das2Id_12415076817021%26as3Listener%3DonLocalConnectionEvent%26pl&sk=jQsY3zE0d-7RPFSSh-LphK4BCDcUMc-YC' tried to access incompatible context 'app:/as2_tubeloc.swf?as3Id=as3Id_12415076817010&as2Id=as2Id_12415076817021&as3Listener=onLocalConnectionEvent&playerAPIUrl=http%3A//www.youtube.com/apiplayer'


Thanks,
Les.

Jigar Patel said:

Ben, First great job on this component. It really saved me a lot of time in my personal project.

My question, I think has to do with the as2_tubeloc.swf file. I have the need to call the YouTube video from a php proxy script. I get the error below, when I play the video straight from YouTube.

I was wondering if the YouTube request is made in the as2_tubeloc.swf file, if so, do you have any ideas how I could call the url from a php proxy script on my server, so I can add a cross domain policy file and serve it to my webpage, and not get the error below?

ERROR MSG below: I masked the website url with localhost.

SecurityError: Error #2121: Security sandbox violation: BitmapData.draw: http://localhost/CreateMagazine.swf cannot access http://s.ytimg.com/yt/swf/cps-vfl96213.swf. This may be worked around by calling Security.allowDomain.

So, instead of calling "http://s.ytimg.com/yt/swf/cps-vfl96213.swf" directly, I would like to call "http://localhost/proxy.php?file=http://s.ytimg.com/yt/swf/cps-vfl96213.swf". This way my proxy script can serve up the video, instead of YouTube allowing me to do some manipulation I need to do.

Any help on this would be greatly appreciated. If you need more information of a link to the site to see the error yourself, please let me know.

Thanks,
Jigar

Jigar Patel said:

Hi Ben, I have not heard anything regarding my previous question. I may have missed an email or you might just be too busy. Please let me know if I should try other avenues to resolve my issue/question.

Thanks,
Jigar

Igor Kurochka said:

Hi, Ben!
there is a problem with tubeLoc when main swf and your as_tubeloc.as wrapper are on the different domains - main swf receives the calls but wrapper is not.
there is opened issue #12 here http://code.google.com/p/tubeloc/issues/detail?id=12&can=1#makechanges

Please, help solve this problem!!!!

Ahmed Nuaman said:

Hey,

TubeLoc is good, but there are little issues with it. So I wrote a tut about how to create your own AS3 wrapper for YouTube Player for both the chromed and chromeless players: http://ahmednuaman.com/blog/2009/06/29/the-youtube-player-api/

Tell me if it's handy.

Leave a comment


Tag Cloud

Question of the Week: Dream App

If you had an unlimited budget and unlimited resources what application would you build and why would you build it?

Answer

Latest Features

Recommended for You

@InsideRIA on Twitter

Archives

  • Or, visit our complete archive.  

About This Site

Welcome to the premiere community site for all things RIA sponsored by O'Reilly Media and Adobe Systems Incorporated.