2

我正在使用新的RTMFP协议和NetGroups在 Flex 中实现对等视频会议应用程序。

假设组的名称是 Group1。我想做的是;当一个新的对等点连接到 Group1 时;为每个加入的同伴创建一个新的视频显示并立即播放他/她的流。

我听on的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;
    }
}

任何帮助表示赞赏..谢谢..

4

2 回答 2

2
     case "NetGroup.MulticastStream.PublishNotify":
          trace(event.info.name)
          break;

     case "NetGroup.MulticastStream.UnpublishNotify":
      trace(event.info.name)
      break;

您可以从上面的代码中获取流名称.....您将使用某个名称发布您的流,并且该名称将出现在这里,我认为当NetStream.Connect.Success触发时,此信息也不确定......干杯

于 2011-06-01T13:44:43.733 回答
1

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*/);
于 2011-01-30T00:18:03.077 回答