[FMS]基于AS3下提示FMS音频质量的源代码
[FMS]基于AS3下提示FMS音频质量的源代码
[FMS]基于AS3下提示FMS音频质量的源代码
- package
- {
- import flash.display.Sprite;
- import flash.events.NetStatusEvent;
- import flash.net.NetConnection;
- import flash.net.NetStream;
- import flash.media.Microphone;
- import flash.media.SoundCodec;
- public class Main extends Sprite
- {
- private var nc:NetConnection;
- private var nsAudio:NetStream;
- private var nsVideo:NetStream;
- private var nsPlayVideo:NetStream;
- private var nsPlayAudio:NetStream;
- public function Main():void
- {
- nc=new NetConnection();
- nc.client = this;
- nc.addEventListener(NetStatusEvent.NET_STATUS,netStatusHandler);
- nc.connect("rtmp://localhost/TestAudioMore","我心空");
- }
- private function netStatusHandler(e:NetStatusEvent)
- {
- var code:String = e.info.code;
- switch (code)
- {
- case "NetConnection.Connect.Success" :
- publishAudio(0);
- break;
- default :
- break;
- }
- }
- //分别发布音频,视频
- private function publishAudio(id)
- {
- if (nsAudio==null)
- {
- nsAudio = new NetStream(nc);
- nsAudio.client = this;
- nsAudio.bufferTime = 2;
- var mic:Microphone = Microphone.getMicrophone();
- if (mic!=null)
- {
- mic.codec = SoundCodec.SPEEX;
- mic.encodeQuality = 4;
- mic.noiseSuppressionLevel = 0;
- mic.setSilenceLevel(10,1000);
- mic.setUseEchoSuppression(true);
- mic.setLoopBack(false);
- mic.gain = 50;
- nsAudio.attachAudio(mic);
- }
- nsAudio.publish("audio"+id,"live");
- }
- }
- private function publishVideo(id)
- {
- if (nsVideo==null)
- {
- nsVideo=new NetStream();
- nsVideo.client = this;
- nsVideo.bufferTime = 2;
- var cam:Camera = Camera.getCamera();
- if (cam!=null)
- {
- cam.setQuality(0,80);
- cam.setMode(160,130,7);
- nsVideo.attachCamera(cam);
- }
- nsVideo.publish("video"+id,"live");
- }
- }
- //分别播放视频音频
- private function playVideo(id)
- {
- clearVideoStream();
- nsPlayVideo=new NetStream(nc);
- var vid:Video=new Video();
- vid.attachNetStream(nsPlayVideo);
- vid.width=240;
- vid.height=150;
- addChild(vid);
- nsPlayVideo.play("video"+id);
- }
- /**
- *CuPlayer.com 清除视频
- */
- private function clearVideoStream(clearPublish:Boolean=false)
- {
- if (nsPlayVideo)
- {
- nsPlayVideo.close();
- nsPlayVideo = null;
- }
- if (nsVideo&&clearPublish)
- {
- nsVideo.close();
- nsVideo = null;
- }
- }
- /**
- *清除音频
- */
- private function clearAudioStream(clearPublish:Boolean=false)
- {
- if (nsPlayAudio)
- {
- nsPlayAudio.close();
- nsPlayAudio = null;
- }
- if (nsAudio&&clearPublish)
- {
- nsAudio.close();
- nsAudio = null;
- }
- }
- public function Welcome(str)
- {
- trace(str,",CuPlayer.com欢迎你的到来。义无反顾,彻底的放下心扉");
- }
- }
- }
[FMS]基于AS3下提示FMS音频质量的源代码
热门文章推荐
- [HLS]做自己的m3u8点播系统使用HTTP Live Streaming(HLS技术)
- [FMS]FMS流媒体服务器配置与使用相关的介绍
- [AS3]什么是M3U8,与HTML5的区别是什么
- AS2.0 让flash自适应全屏,并且不自动缩放
- [AS3]as3.0的sound类常用技巧整理
- [AS3]as3与ByteArray详解、ByteArray介绍、ByteArray用法
- 关于RTMP,RTMPT,RTMPS,RTMPE,RTMPTE协议的介绍
- [JS]分享浏览器弹出窗口不被拦截JS示例
请稍候...