【问题标题】:red5: how can i send microphone stream?red5:如何发送麦克风流?
【发布时间】:2011-12-22 10:02:39
【问题描述】:

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

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

【问题讨论】:

    标签: apache-flex red5


    【解决方案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");
        }
    }
    

    从客户端,要播放现场声音,请将您的网络流也连接到当前网络连接:

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

    【讨论】:

    • 感谢您的回复。我已经尝试过了,但服务器端代码不清楚。在服务器端,我无法获取麦克风字节。如何以编程方式播放服务器上的客户端流或客户端上的服务器麦克风流?
    猜你喜欢
    • 2015-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多