0

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.

icecreamscoop
  • 71
  • 2
  • 10
  • Is this a chat / conversation app ? In that case, how / from where did you get the names of others's streams to connect to ? – akmozo Dec 11 '15 at 10:57
  • You need to write something on the server side. You can make a function that can send a list of all the connected stream names, or a remote shared object, or just rename them on the server side when they connect to something unique. – BadFeelingAboutThis Dec 11 '15 at 17:09

0 Answers0