2011-12-22 46 views
0

我使用red5和flex。实际上,我的目标是将麦克风流从服务器发送到客户端,并在客户端播放。同样,将麦克风流从客户端发送到服务器,然后在服务器端播放。无需存储直播信息流。red5:我怎么发送麦克风流?

这可能吗?我怎么能在red5和flex中做到这一点?

回答

0
private var nc:NetConnection; 
private var mic:Microphone; 

private function init():void 
{ 
    nc=new NetConnection ; 
    nc.connect (your rtmppath,"anchor"); 
    mic=Microphone.getMicrophone(); 
    mic.rate=11; 
    nc.addEventListener (NetStatusEvent.NET_STATUS,checkConnect); 
} 

private function checkConnect (e:NetStatusEvent) 
{ 
    good=e.info.code == "NetConnection.Connect.Success"; 
    if (good) 
    { 
     this.attachAudio (mic); 
     this.publish (stream,"live"); 
    } 
} 

从客户端,播放现场声音,与目前的netconnection还连接您的NetStream:

private var nc:NetConnection; 
private var mic:Microphone; 
private var netstream:NetStream = new NetStream 
private function init():void 
{ 
    nc=new NetConnection ; 
    nc.connect (your rtmppath,"viewer"); 
    nc.addEventListener (NetStatusEvent.NET_STATUS,checkConnect); 
} 

private function checkConnect (e:NetStatusEvent) 
{ 
    good=e.info.code == "NetConnection.Connect.Success"; 
    if (good) 
    { 
     var vid:Video = new Video 
     this.attachNetStream(ns) 
     netStream.play(presentation); 
    } 
} 
+0

谢谢大家的响应。我已经尝试过,但服务器端代码不清楚。在服务器端,我无法获得麦克风字节。我怎样才能以客户端编程方式在服务器或服务器麦克风流上播放客户端流? – 2011-12-22 14:18:05