首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何获取流的名称(RTMFP NetGroup问题,Flex/AS3)

如何获取流的名称(RTMFP NetGroup问题,Flex/AS3)
EN

Stack Overflow用户
提问于 2011-01-29 16:20:39
回答 2查看 3.6K关注 0票数 2

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

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

我听NetStatus事件的NetConnection"NetStream.Connect.Success";我想添加新的对等点,并播放他/她的流。

但我的问题是:

我将如何知道流的名称,以便我可以播放该流的加入同行。NetStream.Connect.Success只会给我event.info.stream属性,但我找不到要为该特定对等方播放的流的名称。

下面是代码的简短版本:

代码语言:javascript
复制
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;
    }
}

任何帮助都是非常感谢的。谢谢..。

EN

回答 2

Stack Overflow用户

发布于 2011-06-01 13:44:43

代码语言:javascript
复制
     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。

票数 2
EN

Stack Overflow用户

发布于 2011-01-30 00:18:03

streamIn = new NetStream(conn, NetStream(e.info.stream).farID

代码语言:javascript
复制
//...
streamIn.receiveVideo(true);
streamIn.receiveAudio(true); 
streamIn.play(/*here you need to use the string you pass to NetStream.publish() on the other side*/);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4837924

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档