I am currently building a FlashComm and Flex application to do the following:

I am building this app. Based on Christophe Coenraet and Matt Chotin's
LiveMediaDisplay class and sample application.

How it should work:
If Person A logs in, he can see his stream and Person B's stream.
When Person B logs in, he can see his stream and Person A's stream.

Users can only log-in based on one of two names: PersonA or PersonB.
Depending on your login, I publish your name (PersonA or PersonB) as
the streamName (see webCam.as). After you log-in, I set the
streamNames to both of these known names (see app.mxml).

What's wrong:
When Person A logs in, he can see his stream and Person B's stream,
which is correct, be selecting the stream1() function or stream2()
function.
When Person B logs in, he can ONLY CHOOSE between his stream or Person
B's stream. He can always get one OR the other, but never both.

Notes: I have removed the userList and chat sections.

App.mxml
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"; 
xmlns:c="collaboration.*"

backgroundColor="#7D8FA8">

<mx:Style source="main.css"/>

<mx:Script>
<![CDATA[
function getView() {

if (service.userName.toLowerCase() == 'personA'){
lmdCam1.streamName = 'personA';
lmdCam2.streamName = 'personB';
break;
} else {
if (service.userName.toLowerCase() == 'personB'){
lmdCam1.streamName = 'personB';
lmdCam2.streamName = 'personA';
break;
} else {
mx.controls.Alert.show('You must log-in as a personB or personA')
}
}
}


function stream1() {
// NOTES: When logged in as personB, it will do one stream OR the
other but not both!

lmdCam1.streamName = 'personB';
mx.controls.Alert.show('stream1');
}
function stream2() {

lmdCam2.streamName = 'personA';
mx.controls.Alert.show('stream2');
}


]]>
</mx:Script>

<c:RTMPService id="service" url="rtmp://172.16.200.205/rmaxmeeting"/>

<c:WebCam id="webCam" service="{service}" streamName="{service.userName}"/>

<mx:Panel title="Collaboration" width="300" height="100%" marginTop="8">

<c:Logon service="{service}"/>

<mx:VBox width="100%" height="100%" horizontalAlign="center">
<c:LiveMediaDisplay id="lmdCam1" rtmpURL="{service.url}" width="200"/>
<mx:Button label="{webCam.started?'Stop My Cam':'Start My Cam'}"
click="webCam.toggle()"
/>
</mx:VBox>

<mx:VBox width="100%" height="100%" horizontalAlign="center" >
<c:LiveMediaDisplay id="lmdCam2" rtmpURL="{service.url}" width="200"/>
<mx:Button label="{webCam.started?'DisConnect Peer':'Connect Peer'}"
click="getView()" />
<mx:Button label="stream1" click="stream1()" />
<mx:Button label="stream2" click="stream2()" />
</mx:VBox>

</mx:Panel>

</mx:Application>

webCam.as
import collaboration.RTMPService;

class collaboration.WebCam {

public var service: RTMPService;
public var streamName: String;
public var started: Boolean=false;

private var ns: NetStream;


function toggle()
{
if (started)
stopCamera();
else
startCamera();
}

function startCamera()
{
// started=true;

var camera = Camera.get();
camera.setMode(320, 240, 15);
camera.setQuality(500000, 60);
camera.setKeyFrameInterval(24);

ns=new NetStream(service.nc);
ns.attachVideo(camera);
ns.attachAudio(Microphone.get());

ns.publish(service.userName, "live");

}


function stopCamera()
{
started=false;
ns.attachVideo(null);
ns.close();
}

}

Any help is much obliged,
Dave


Reply via email to