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.
Over and out.