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

发布于 2024-10-15 01:54:34 字数 1804 浏览 6 评论 0原文

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

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

我监听 NetConnection"NetStream.Connect.Success"NetStatus 事件;我想添加新的同伴并播放他/她的流。

但我的问题是:

我如何知道流的名称,以便我可以为加入的对等方播放该流。 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;
    }
}

感谢任何帮助.. 谢谢..

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..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

撕心裂肺的伤痛 2024-10-22 01:54:34
     case "NetGroup.MulticastStream.PublishNotify":
          trace(event.info.name)
          break;

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

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

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

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

You can get stream name from the above code.....you will publsh your stream with some name and that name will appear here, I think when NetStream.Connect.Success fires then this info also appears not sure......cheers

故事↓在人 2024-10-22 01:54:34

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*/);

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*/);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文