4

I am struggling to find any information on the FCSubscribe methods used by various CDNs. I need to implement the methods in a custom video player.

I would like an official specification for these methods, but even a SO search for "FCSubscribe" produces only 2 results. I've managed to find scraps of code around the web, but nothing concrete.

I have managed to build a working player after reading all these code scraps, but am not sure of it's robustness because of lack of any documentation.

The following is a basic outline of my code so far:

public function connectCDN() :void
{
    netConnection.client = {
        onFCSubscribe : onFCSubscribe
    };

    netConnection.call('FCSubscribe', null, streamName);

    netStream.play(streamName);
}

public function onFCSubscribe(...args) :void
{
    //Don't know what to do here???
}

There's not really much to it.

My specific concerns are:

  • Should I start playing the NetStream directly after calling FCSubscribe, or should I wait for a callback?

  • I've implemented the onFCSubscribe callback, but I don't know what I'm supposed to do here. Args contains a structure like info.code (similar to a NetStatusEvent).

  • In other implementations I've seen onFCUnsubscribe callbacks, should I also implement this? What for?

Drahcir
  • 11,772
  • 24
  • 86
  • 128

1 Answers1

0

For those looking to add onFCSubscribe support, here's a couple links that helped me.

First, ensure that your rtmp stream plays by checking it here: http://support.akamai.com/flash/index.html?autostart=true&url=rtmp://REPLACE-WITH-YOUR-RTMP-STREAM-URL

More to your point, I found these two resources helpful:

You use the onFCSubscribe and onFCUnsubscribe to open and close the netStream

public var hostName:String = "rtmp://client.flash.internapcdn.net/client/live_1";
public var streamName:String = "thestream";
public var netConnection:NetConnection;
public var netStream:NetStream;
public var video:Video;

public function BasicLiveVideo()
{
    video = new Video();
    this.addChild(video);
    netConnection = new NetConnection();
    netConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
    var rtnClient:Object = new Object();

    rtnClient.onFCSubscribe = function (info:Object){
        netStream.play(streamName);
        video.attachNetStream(netStream);
    }

    rtnClient.onFCUnsubscribe = function (info:Object){
        netStream.close();
    }

    netConnection.client = rtnClient;
    netConnection.connect(hostName);
}
potench
  • 3,802
  • 1
  • 28
  • 39