如何获取流的名称(RTMFP NetGroup问题,Flex/AS3)
我正在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以从上面的代码中获取流名称......您将使用某个名称发布您的流,该名称将出现在此处,我认为当
NetStream.Connect.Success
触发时,此信息也会出现不确定……干杯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......cheersstreamIn = new NetStream(conn , NetStream(e.info.stream).farID
streamIn = new NetStream(conn, NetStream(e.info.stream).farID