本文介绍了red5:如何发送麦克风流?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

这可能吗?我该如何在red5和flex中做到这一点?

Is this possible? how can i do it in red5 and flex?

推荐答案

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

要在客户端播放现场声音,请同时将您的netstream与当前的netconnection连接:

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

这篇关于red5:如何发送麦克风流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 18:31