I am working on a project that is going to have an API that allows the user to insert video. The API is basically an ActionScript class that attaches a property when the user publishes their SWF. When the SWF is loaded into the main SWF program, it has access to the special functions in the SWF file. First, I just used the FLVPlayback and a registry function so the app would have access to it’s functions. That’s fine, but the user has to host an FLV for this to be effective. Not everyone has a server at their disposal, so this is the reason to build on existing video sites. Also, your not shit as a dev guy unless your mashable Web 2.0 savvy.
Fortunately, the popular sites have APIs out there ready and available to get content and media. A developer is expected to know what they have available to them and what will make the job easier for them. Being in the know about Facebook shit is actually a job requirement.
So, first one I thought of was the giant, YouTube. YouTube’s player is AS2 and to use it in an AS3 project you need to wrap it in an AS3 SWF and use LocalConnection to interface with it. There are a few solutions out there but in the end it is a band aid, until YouTube puts together an alternative player API. After fumbling with this, and saving the failing code to my repository for later, I went to Vimeo.
Vimeo has a pretty cool player and the thing that puts it over the top for my app is that it is written in ActionScript 3. But, as with everything, it isn’t perfect. YouTube has a good API page, and some decent forums, and support of the widespread dev community. Vimeo does not. Their API page is nothing short of pathetic, to say the least. They have one example and it doesn’t work. I found a working example on their fourm. At the top of the API page (as of this posting) they have a blurb that says this: You may have noticed that there are some inaccuracies in this documentation. We working on improving it. How about now? In the time it took to put up that asinine message you could of updated the code. That is annoying. Also, there is no public functions to be seen what so ever. Searching on the forums, someone found play, load and unload, which kind of works like stop. I also needed an event at the end of the video. Pretty standard stuff as far as a video API goes. Looks like I am going to have to Sherlock Holmes this shit.
There are some API functions exposed that I found by debugging the player. Use these at your own risk as they are not documented and may change. The way I figure it as soon there is an update to the player changing the functions to the real deal functions is no biggie. For the here and now I need ways to respond to the end of a video, play, pause and stop.
It seems that all the API commands are prefaced with api_ before the function name. Below are a list of functions that seem to be exposed for API usage. I have not tested all of them, but for what it’s worth here is a list. Some need parameters to work and my debugger isn’t specific about the datatype for these. So, here are the method signatures as far as I can tell. The debugger shows the wildcard (*) for datatypes that are not top level, so it could be anything specific to the Vimeo player. Really unknown unknowns are marked with a question mark.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
function api_changeColor(?):? function api_changeOutro(one:String, two:*):void function api_disableHDEmbed():void function api_enableHDEmbed():* function api_isLoaded():Boolean function api_isPaused():Boolean function api_isPlaying():Boolean function api_likeClip():void function api_loadVideo(one:int):void function api_pause():* function api_play():* function api_seekTo(?):? function api_setOnFinishCallback(one:String):void function api_setOnPauseCallback(one:String):void function api_setOnProgressCallback(one:String):void function api_setSize(one:int, two:int):void function api_toggleElement(one:String, two:*):* function api_toggleFullscreen():void function api_toggleLoop():void function api_togglePlayPause(one:Boolean):void function api_unload():void function api_unload_other_players():*