red5: how can i send microphone stream?

故事扮演 提交于 2019-12-11 15:32:32

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!