YouTube Direct Upload in ActionScript3
An app I wrote needed the following features:
- Application has to run in the browser as a SWF.
- Application will run in filesystem mode (file://).
- Application will not have server side (except for YouTube).
- Application will have to login to YouTube using ClientLogin instead of AuthSub to avoid redirects.
- Application will have to upload a manipulated ByteArray, not directly from FileReference.browse().
First thing you do: Search Google for YouTube+Upload+ActionScript, which brings up many results, including this library.
Unfortunately, none of the results presented a solution to the above, and surprisingly, the AS3 DataAPI library doesn’t even implement an upload API.
A few other search queries… no results.
So, I turned to the YouTube API docs, looked at the PHP implementations and the result is this class which I’m sharing with you now.
Introducing: YouTubeDirectUploader.as – A utility class for uploading to YouTube using email and password.
The class provides two methods of uploading:
- Using FileReference and browse() – which will opt the user to select their video to upload.
- Using a ByteArray – which allows the Application to manipulate the FLV before uploading to YouTube (what was needed in my case).
It was also designed to be used as a declared object in MXML, just to ease the use and allow bindings to form elements.
Check/Fork the code on GitHub. Share your thoughts below : )