I have been developing an AS3 library for the video publishing company Castfire on my own for the past little while and recently got in touch with them about continuing the endeavor. I thought it was a shot in the dark but they were more than willing to help out and so here is the first of, I hope, many articles on the Castfire API and the class library I am working with them to create for it.
The point of this library is to allow Flash devs like myself to easily access the Castfire API when creating custom video players.
The first class I built utilizes the GetStaticShow method of the Castfire API which takes the URL of an uploaded video and returns the actual url of the encoded video that includes any sponsor ads or other elements added to the video channel.
It’s very simple to use and takes 2 required arguments
1 var GSS:GetStaticShow = new GetStaticShow("URL_FROM_CASTFIRE,"API-KEY");
The class then creates the URL and requests it as XML from Castfire. Once the data has been returned one of two events are fired indicating whether the the request was valid or not. Here’s a snippet showing the EventListeners:
123 GSS.addEventListener(GetStaticShow.XML_READY, get_video_url);GSS.addEventListener(GetStaticShow.XML_ERROR, bad_xml_returned);
If all has gone to plan, the GetStaticShow.XML_READY event should have fired and you can now access the live URL for the video with the getter method feedUrl();
Currently the XML_ERROR event is fired if the attribute “status” in the returned XML is not equal to ‘ok’.
I will be adding in more XML_ERROR events to reflect the reason why the request failed in the near future.
[kml_flashembed publishmethod=”static” fversion=”10.1.0″ movie=”http://www.ryanwelcher.com/wp-content/uploads/2011/04/OSMF.swf” width=”640″ height=”360″ fid=”flasher” targetclass=”flashmovie”]
The very simple demo above is based on Lee Brimelow‘s fantastic introductory tutorial on OSMF. I should be extremely clear that the OSMF code is all his, in fact I downloaded his tutorial files and used them as a starting point. All I did was add in the GetStaticShow class and use it to generate the URL that is passed to the OSMF object.
I chose this route to demonstrate the simplicity of the class and how with the combination of these two codebases you can be up and running with a simple player in minutes all while taking advantage of the real-time video stream encoding that comes with using Castfire, that and I’m a big fan of Lee’s and wanted to give a shout out!
You should watch Lee’s tutorial and download the files to get a sense of how OSMF works. I have included the modified version of his main OSMF.as file along with the GetStaticShow.as file and you can download it here – GetStaticShowExample.zip
( I should also mention that the video I used is from a tutorial over at VideoCopilot.net – another favorite of mine. )
Over and out.