red5:我怎样才能发送麦克风流?

时间:2011-12-22 10:02:39

标签: flex red5

我正在使用red5和flex。实际上我的目标是将麦克风流从服务器发送到客户端并在客户端播放。同样,从客户端向服务器发送麦克风流,并在服务器端播放。无需存储实时流。

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

1 个答案:

答案 0 :(得分: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");
    }
}

从客户端播放现场声音,将您的网络流与当前的网络连接连接起来:

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);
    }
}