Recently I had the task of recreating a video player for a customer for which no source code was available. The player needed to support on demand and live streaming, so I opted for an OSMF based player - why reinvent the wheel?

Things went well until the time came to add the live streaming support. The chosen CDN uses the FCSubscribe method for live streaming. In case you don't know, FCSubscribe is a serverside method which the player needs to call in order to instruct the CDN to deliver the requested stream to the edge server that you are connected to in order to play the stream.
Some CDNs (including Akamai and Limelight) provide custom OSMF plugins for this task, and if your CDN does the same then you have nothing else to do apart from using their plugin and you are set. However some CDNs do not (yet) provide such plugins, and since the task of creating one is no mean feat (and it was certainly not part of the budget for the player I was working on), another solution had to be found.

I reached out to some of my friends in the community and Bob Wohl came up with an excellent and very simple trick: use a second NetConnection to connect to the edge server and invoke FCSubcribe ourself, then play the stream once it is available. Or in other ways, handle the FCSubscribe logic outside of OSMF. Right, I remember doing this a while back with the FLVPlayback component.

I created an ActionScript class for this purpose based on some code snippets from Bob and bingo, Bob's your uncle. (yeah sorry, couldn't resist!)

Find the code for the class as a gist below. Hope it helps someone and if it does don't thank me, thank Bob.