我正在使用新的RTMFP协议和NetGroups在Flex中实现点对点视频会议应用程序。
假设这个组的名称是Group1。我想做的是,当一个新的对等点连接到Group1时,为每个加入的对等点创建一个新的视频显示,并立即播放他/她的流。
我听NetStatus事件的NetConnection和"NetStream.Connect.Success";我想添加新的对等点,并播放他/她的流。
但我的问题是:
我将如何知道流的名称,以便我可以播放该流的加入同行。NetStream.Connect.Success只会给我event.info.stream属性,但我找不到要为该特定对等方播放的流的名称。
下面是代码的简短版本:
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;
}
}任何帮助都是非常感谢的。谢谢..。
发布于 2011-06-01 13:44:43
case "NetGroup.MulticastStream.PublishNotify":
trace(event.info.name)
break;
case "NetGroup.MulticastStream.UnpublishNotify":
trace(event.info.name)
break;您可以从上面获得流名,code.....you将用某个名称公开您的流,该名称将出现在这里,我认为当NetStream.Connect.Success触发时,此信息也不会显示为sure......cheers。
发布于 2011-01-30 00:18:03
streamIn = new NetStream(conn, NetStream(e.info.stream).farID
//...
streamIn.receiveVideo(true);
streamIn.receiveAudio(true);
streamIn.play(/*here you need to use the string you pass to NetStream.publish() on the other side*/);https://stackoverflow.com/questions/4837924
复制相似问题