[FMS]FMS文字和视频方面的示例代码
FMS服务器的设置简单的仿照(一)就可以了,这段代码延续(一),加上了视频和语音发布,主要用到netstream.publish()方 法,该方法也可以用于视频在线录制,除了检测摄相头和MIC状态的代码外,就增加了十几行的视频发布代码
FMS服务器的设置简单的仿照(一)就可以了,这段代码延续(一),加上了视频和语音发布,主要用到netstream.publish()方 法,该方法也可以用于视频在线录制,除了检测摄相头和MIC状态的代码外,就增加了十几行的视频发布代码,有关摄相头和MIC的详细设置我并没有写,只是 让大家看清楚它的工作原理,没有摄相头的朋友(我就没有摄相头)可以这样测试:打开麦克风说话,如果能听到回音就说明发布成功了复制内容到剪贴板代码://建立与服务器的连接.
- var sv_uri:String = "rtmp:/recordstream";
- var my_nc:NetConnection = new NetConnection ();
- my_nc.connect (sv_uri);
- //新建共享对象;
- my_nc.onStatus = function (thisObj:Object){
- if (thisObj.code == "NetConnection.Connect.Success"){
- info_txt.text = "连接服务器成功!!";
- info_txt.textColor = 0x66CC00;
- }
- else{
- info_txt.text = "连接服务器失败!!"
- info_txt.textColor = 0xFF0000;
- }
- }
- var user_rso:SharedObject = SharedObject.getRemote ("chat_rso", my_nc.uri, true);
- user_rso.connect (my_nc);
- //建立摄相头和麦克风对象
- this.cam = Camera.get();
- this.mic = Microphone.get();
- videobox.attachVideo(this.cam);
- videobox.attachAudio(this.mic);
- send_ns = new NetStream(my_nc);
- send_ns.attachVideo(this.cam);
- send_ns.attachAudio(this.mic);
- send_ns.publish("humorguy");
- get_ns = new NetStream(my_nc);
- get_ns.play("humorguy");
- videobox2.attachVideo(get_ns);
- //更新聊天内容
- user_rso.onSync = function (){
- chatOutput_txt.text += newline+this.data.chatname +":"
+ this.data.chatcontent;- chatOutput_txtchatOutput_txt.scroll = chatOutput_txt.maxscroll+1;
//确保最新消息能显示在输出框里- }
- //回车键发送聊天内容
- function myOnKeyDown() {
- if (Key.getCode() == 13) {
- if(chatInput_txt.text != undefined && chatInput_txt.text !=
user_rso.data.chatcontent){- Selection.setFocus(chatInput_txt);
- user_rso.data.chatcontent = chatInput_txt.text;
- if(name_txt.text != "" && name_txt.text != user_rso.data.chatname){
- user_rso.data.chatname = name_txt.text;
- }
- }
- }
- }
- var myListener:Object = new Object();
- myListener.onKeyDown = myOnKeyDown;
- Key.addListener(myListener);
- //构造检测摄相头和麦克风状态的函数
- function checkforCam_Mic() {
- camArray = Camera.names;
- micArray = Microphone.names;
- if (camArray.length>=1) {
- temp_cam = Camera.get();
- if (temp_cam == -1) {
- camInfo_txt.text = '视频设备正忙!';
- camInfo_txt.textColor = 0xFFCC00;
- } else {
- camInfo_txt.text = '视频设备可用!';
- camInfo_txt.textColor = 0x66CC00;
- }
- delete temp_cam;
- } else if (camArray.length == 0) {
- camInfo_txt.text = '没有视频设备!';
- camInfo_txt.textColor = 0xFF0000;
- }
- //检测麦克风状态
- if (micArray.length>=1) {
- temp_mic = Microphone.get();
- if (temp_mic == -1) {
- camInfo_txt2.text = '麦克风正忙!';
- camInfo_tx2t.textColor = 0xFFCC00;
- } else {
- camInfo_txt2.text = '麦克风可用!';
- camInfo_txt2.textColor = 0x66CC00;
- }
- delete mic_cam;
- } else if (micArray.length == 0) {
- camInfo_txt2.text = '没有麦克风!';
- camInfo_txt2.textColor = 0xFF0000;
- }
- }
- checkforCam_Mic();
热门文章推荐
- [FMS]adobe FMS配置实现(FMS/HLS/HDS)功能经验
- [HLS]HTTP Live Streaming流与TS流比较
- [FMS]adobe FMS(flash media server )服务器安装过程
- [FMS]fms5.0的hls(HTTP Live Streaming)技术实现跨平台点播与
- [FMS]FMS之HTTP Live Streaming (HLS)视频直播技术
- [hls]m3u8视频如何处理成加密?
- [海康]视频监控环境中配置组播模式
- [FMS]基于fms搭建在线hls跨平台直播环境(组图)
请稍候...