I'm implementing a peer-to-peer video conference application in Flex using the new RTMFP protocol and NetGroups..
Let's say the name of the group is Group1. What I want to do is; When a new peer connects to Group1; create a new video display for each joining peer and play his/her stream right away.
I listen to the NetStatus
event of the NetConnection
and on "NetStream.Connect.Success"
; I want to add the new peer and play his/her stream.
But my problem is:
How will I know the name of the stream so I can play that stream for that joining peer. NetStream.Connect.Success
will only give me event.info.stream
property but I cannot find the name of the stream to be played for that particular peer.
Here is the short version of the code:
private function connect():void
{
var conn:NetConnection = new NetConnection();
conn.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
conn.connect(rtmfpServer);
}
private function setupGroup():void
{
var gspec:GroupSpecifier = new GroupSpecifier("Group1");
gspec.multicastEnabled = true;
gspec.postingEnabled = true;
gspec.serverChannelEnabled = true;
var group:NetGroup = new NetGroup(conn, gspec.groupspecWithAuthorizations());
group.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
}
protected function onNetStatus(e:NetStatusEvent):void
{
switch (e.info.code)
{
case "NetConnection.Connect.Success": //connected to the server
setupGroup(); //create and connect to the group
break;
case "NetGroup.Connect.Success": //connected to the group
publishMyVideo(); //create a player for my own video and publish it to the group
break;
case "NetStream.Connect.Success": //a new stream is connected
if (NetStream(e.info.stream) != myStream) //if this is not my own stream; it's a new joining peer...
{
createPlayerForPeer(); //Create a video player for each joning peer
playPeersVideo(); //what is the stream name to play?
}
break;
}
}
Any help is appreciated.. thanks..
streamIn = new NetStream(conn, NetStream(e.info.stream).farID