问题
i am using red5 and flex. Actually my objective is to send microphone stream from the server to the client and play it on the client side. Similarly send microphone stream from client to server and play it on the server side. No need to store the live stream.
Is this possible? how can i do it in red5 and flex?
回答1:
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");
}
}
From client-side, to play live sound, connect your netstream with current netconnection also:
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);
}
}
来源:https://stackoverflow.com/questions/8602244/red5-how-can-i-send-microphone-stream