Adobe 65029121 - Flash Media Streaming Server Developer's Manual page 45

Developer's guide
Hide thumbs Also See for 65029121 - Flash Media Streaming Server:
Table of Contents

Advertisement

Write the client-side code
Create an ActionScript class. In your class, create a NetConnection object, add a
1
connect to the server.
Add the ActivityEvent handler:
2
private function activityHandler(event:ActivityEvent):void {
trace("activityHandler: " + event);
trace("activating: " + event.activating);
}
Write a function to publish the live stream. First, create NetStream, Camera, and Microphone objects:
3
private function publishLiveStream():void {
ns = new NetStream(nc);
ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
ns.client = new CustomClient();
camera = Camera.getCamera();
mic = Microphone.getMicrophone();
...
}
Add ActivityEvent listeners to the Camera and Microphone objects. Then, attach the camera and microphone
4
data to the Video object and the NetStream object, respectively, and call
if (camera != null){
camera.addEventListener(ActivityEvent.ACTIVITY, activityHandler);
video = new Video();
video.attachCamera(camera);
ns.attachCamera(camera);
}
if (mic != null) {
mic.addEventListener(ActivityEvent.ACTIVITY, activityHandler);
ns.attachAudio(mic);
}
if (camera != null || mic != null){
// start publishing
// triggers NetStream.Publish.Start
ns.publish("localNews", "live");
} else {
trace("Please check your camera and microphone");
}
Write the server-side code
Note: The server-side code in the LiveStreams example demonstrates the multipoint publishing feature which lets you
republish streams to additional servers for broadcasting to a wider audience.
Write the
1
application.onConnect()
in the in the documentation/samples/LiveStreams directory in the Flash Media Server root install directory).
These handle connecting the client to the application, and then disconnecting the client.
Write the
2
application.onPublish()
and
application.onDisconnect()
function, which is called when the client publishes a stream:
ADOBE FLASH MEDIA SERVER
event handler, and
netStatus
:
NetStream.publish()
functions, as usual (see main.asc
42
Developer Guide

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash media server

Table of Contents