开发者

Connecting/Streaming to Flash Media Server from SWF

I have access to a flash media server on a CDN. I want t开发者_运维问答o allow people to easily connect to this server. Currenty, they need to an additional software to connect to the FMS. It would be nicer if they could just connect to the server with their browser.

So I assume I need to create a SWF file and connect from this file to the FMS (with Actionscript).

The end result would look like the demo of the jquery webcam plugin, only that the SWF file would establish a connection to the FMS and stream the video to the FMS. http://www.xarg.org/project/jquery-webcam-plugin/

I need to show the dialog to accept a webcam connection and then connect with and stream the video to the server.


Take a look at Chapter 4 of the FMS Dev guide.

In outline you need to do the following:

  • create a NetConnection to the FMS
  • create a NetStream using that connection
  • attach the camera and microphone to the stream (this will automatically trigger the webcam dialog)
  • publish your stream

You will need to add various listeners to pick up on the events such as checking that you have successfully connected to the FMS before creating the NetStream and then starting the recording, etc.

Sample code:

var nc:NetConnection = new NetConnection(); nc.connect("rtmp://myServerName/nameOfFMSapplication/");

var ns:NetStream = new NetStream(nc);

camera = Camera.getCamera(); mic = Microphone.getMicrophone();

ns.attachAudio(camera); ns.attachAudio(mic);

ns.publish("theName ofThisVideoIs", "record");

NB to stop publishing the stream : ns.publish(false);

One of the key things is managing each stage with listeners so that you are sure you are connected etc before you proceed onto the next step. Good Luck!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜