2

新しいRTMFPプロトコルとNetGroupsを使用して、Flex でピアツーピア ビデオ会議アプリケーションを実装しています。

グループの名前が Group1 だとしましょう。私がやりたいことは次のとおりです。新しいピアが Group1 に接続するとき。参加するピアごとに新しいビデオ ディスプレイを作成し、そのストリームをすぐに再生します。

and 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 に答える