Client side FCSubscribe implementation

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

I would like to get an official specification of these methods, but even a SO search for "FCSubscribe" gives only 2 results. I managed to find bits of code on the Internet, but nothing concrete.

I managed to create a working player after reading all these code fragments, but I am not sure of its reliability due to the lack of any documentation.

Below is a basic outline of my code:

 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 are not very many.

My specific problems:

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

  • I implemented the onFCSubscribe , but I don't know what I should do here. Args contains a structure of type info.code (similar to a NetStatusEvent ).

  • In other implementations, I saw onFCUnsubscribe , should I also implement this? What for?

+4
source share
1 answer

For those who want to add onFCSubscribe support, here are a couple of links that have helped me.

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

In my opinion, I found these two resources useful:

You use the onFCSubscribe and onFCUnsubscribe to open and close 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); } 
0
source

Source: https://habr.com/ru/post/1485009/


All Articles