[Turn] Connection Example - Flashcom Developes Read Note 2

xiaoxiao2021-03-06  226

A simple connection server example first ensures that the server is already started, and you can start the service directly below Windows. Run the server start command starting under Linux. Open the connection my_nc = new netConnection (); // creation of the connection object MY_NC.CONNECT (//); // The connection server parameter format is: where the instance name can be omitted RTMP: // localhost: port / appname / InstanceName // Local server can also omit the direct write directly to RTMP: / AppName / InstanceName RTMP: // Host: Port / AppName / InstanceName // Remote Server Note Protocol Type must use RTMP, otherwise the connection failed is a simple implementation method:

// Get and set the camera

Client_cam = Camera.get ();

Live_video.attachvideo (client_cam);

// Establish a remote connection

Function doconnect () {

Client_nc = new netConnection ();

Client_nc.onstatus = function (info) {

Trace ("Level:" Info.Level "Code:" Info.code);

}

Client_nc.connect ("RTMP: // localhost / doc_connect / room_01");

}

// Release video stream

Function Publishme () {

OUT_NS = New NetStream (_Root.Client_nc);

Out_ns.attachvideo (client_cam);

OUT_NS.PUBLISH ("myteststream"); ​​// uses the default Live playback form

}

// Play the video stream

Function Playme () {

IN_NS = New NetStream (_ROT.CLIENT_NC);

Published_video.attachvideo (in_ns);

IN_NS.PLAY ("MyTestStream");

}

After defining these functions, you can use the following code simple implementation.

// Connect to the Server

Doconnect ();

// Publish The Live Stream

Publishme ();

// Play Back The Stream from the Server

Playme ();

转载请注明原文地址:https://www.9cbs.com/read-128921.html

New Post(0)