I have a netstream and I want to publish a stream with its own name, but multiple streams might be published at the same time. What causes the conflict is that all the streams have the same name because I can't figure out how to get other streams' names from other clients and play them, and publish my stream with a different name.
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.events.*;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.URLVariables;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequestMethod;
import flash.media.Microphone;
import flash.media.Sound;
var Mic:Microphone;
var aud:Sound;
var nc:NetConnection = new NetConnection;
nc.client = this;
var istream:NetStream;
var ostream:NetStream;
Security.showSettings("2");
if(Microphone.names.length <= 0) {
// no microphone
} else {
Mic = Microphone.getMicrophone();
Mic.rate = 44;
Mic.setUseEchoSuppression(true);
Mic.setLoopBack(false);
Mic.addEventListener(ActivityEvent.ACTIVITY, activityHandler);
Mic.addEventListener(StatusEvent.STATUS, statusHandler);
}
icon_btn.addEventListener(MouseEvent.MOUSE_DOWN, talkDown);
icon_btn.addEventListener(MouseEvent.MOUSE_UP, talkUp);
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
nc.addEventListener(NetGroup.MulticastStream.PublishNotify
nc.connect("rtmp://server.xxxxxxxxxxxxx.us:1935/oflaDemo");
function talkDown(e:MouseEvent):void {
ostream.publish("mcp");
istream.receiveAudio(false);
}
function talkUp(e:MouseEvent):void {
ostream.close();
istream.receiveAudio(true);
timer.stop();
}
function netStatusHandler(event:NetStatusEvent):void {
trace(event.info.code)
ostream = new NetStream(nc);
istream = new NetStream(nc);
istream.play("mcp");
ostream.attachAudio(Mic);
}
function activityHandler(event:ActivityEvent):void {
trace("activityHandler: " + event);
}
function statusHandler(event:StatusEvent):void {
trace("statusHandler: " + event);
}
By reading the code, I'm pretty sure you figured out what the conflict is.