zoukankan      html  css  js  c++  java
  • 视频会议开发分析

    <?xml version="1.0" encoding="utf-8"?>

    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:Script>
     <![CDATA[
      import flash.events.NetStatusEvent;
      import flash.net.NetConnection;
       
      import flash.display.Sprite;
      import flash.media.Camera;
      import flash.media.Video;
      import flash.text.TextField;
      import mx.controls.Alert;
      import cn.mediasky.media.*;
      
         import flash.display.Sprite;
         import flash.events.*;
         import flash.media.Microphone;
         import flash.system.Security;
         import flash.system.SecurityPanel;
         import flash.media.Microphone;
         import flash.media.SoundLoaderContext;
      
      private var nc:NetConnection;
      private var active_mic:Microphone = Microphone.getMicrophone();
      private   function ConnectHandler():void
      {
       
       trace("开始连接服务");
       nc=new NetConnection();
       nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
                nc.connect("rtmp://www.resincrm.com/HelloServer");   
       
      }
      public function CloseHandler():void
      {
       trace("关闭连接");
       nc.close(); 
      }
      public  function netStatusHandler(event:NetStatusEvent):void
      {
               trace("connected is: " + nc.connected);
       trace("event.info.level: " + event.info.level);
       trace("event.info.code: " + event.info.code);
       
       switch (event.info.code)
                {
                    case "NetConnection.Connect.Success":
                     Alert.show("Congratulations! you're connected" + "\n");
                     break;
                    case "NetConnection.Connect.Rejected":
                     trace ("Oops! the connection was rejected" + "\n");
                     break;
        case "NetConnection.Connect.Closed":
         trace("Thanks! the connection has been closed" + "\n");
         break;
            }
       }
              
                public var cam:Camera;
       public function checkCamBusy(userCam:Camera):void
       {
        var chkTime:Number=0;
        var intervalID:Number;
        function callback():void
        {
         if(userCam.currentFPS>0)
         {
          //设备可用
          clearInterval(intervalID);
         }
         else
         {
          chkTime++;
          if(chkTime>30)
          {
           //设备忙
           clearInterval(intervalID);
     
           //Alert.show("摄像头被占用");
          }
         }
         
        }
        intervalID = setInterval(callback, 50);
       }
                public function initCamera():void {
                    // Initialize the variable.
                    cam = Camera.getCamera();
                 var mic:Microphone = Microphone.getMicrophone();
                // Security.showSettings(SecurityPanel.MICROPHONE);

                 mic.addEventListener(StatusEvent.STATUS, this.onMicStatus);

                        
                 if (mic != null) {
                     mic.setUseEchoSuppression(true);
         mic.setLoopBack(true);//本地响声,如果不用耳机会有回声
                     mic.addEventListener(ActivityEvent.ACTIVITY, activityHandler);
                     mic.addEventListener(StatusEvent.STATUS, statusHandler);
                 }               
                    if(cam!=null)
                    {
                     cam.addEventListener(StatusEvent.STATUS,CameraStatusHander);
                     cam.setMode(160,120,15);
                     
                     
                     myVid.attachCamera(cam);
                     checkCamBusy(cam);
                    }
                    else
                    {
                     Alert.show("摄像头已经被其它应用程序使用,请关闭已占用的程序后再试!");
                    }
                }
       public function onMicStatus(event:StatusEvent):void
       {
           if (event.code == "Microphone.Unmuted")
           {
               Alert.show("Microphone可以访问了.");
           }
           else if (event.code == "Microphone.Muted")
           {
                Alert.show("Microphone access was denied.");
           }
       }           
                public function CameraStatusHander(event:StatusEvent):void
                {
                     switch (event.code)
            {
                case "Camera.Muted":
                    Alert.show("Camera用户单击了'拒绝'。");
                    break;
                case "Camera.Unmuted":
                    Alert.show("Camera用户单击了'接受'。");
                    break;
            }

                }
            private function activityHandler(event:ActivityEvent):void {
                Alert.show("activityHandler: " + event);
            }

            private function statusHandler(event:StatusEvent):void {
                Alert.show("statusHandler: " + event);
            }  

            
     ]]>
    </mx:Script>

     <mx:Button x="10" y="538" label="Connect" id="btnConnect"  click="ConnectHandler();"/>
     <mx:Button x="108" y="538" label="Close" id="btnClose" click="CloseHandler();"/>
     <mx:Label x="211" y="542" width="109" id="lbInfo"/>
     <mx:Button x="10" y="468" label="Camera" id="btnVideo" click="initCamera();"/>

     
     <mx:Panel x="10" y="10" width="183" height="165" layout="absolute" id="cam1" title="黄和清" fontFamily="Arial" fontSize="12" color="#0B0D3C">
        <mx:VideoDisplay id="myVid" width="160" height="120"
            creationComplete="initCamera();" x="0" y="0"/> 
     </mx:Panel>
     
    </mx:Application>

  • 相关阅读:
    黑客网银木马服务器曝光 14家银行网银遭监控 狼人:
    卡巴斯基实验室CE0来华启动卡巴斯基安全中国行 狼人:
    天清汉马UTM获“北京市自主创新产品”称号 狼人:
    IBM称欧亚受Conficker病毒感染最严重 狼人:
    卡巴斯基联手功夫巨星成龙 五月鸟巢开唱 狼人:
    微软4月14日起不再为所有XP用户提供安全补丁 狼人:
    卡巴斯基爱好者见面会 卡巴斯基先生与卡fans亲密互动 狼人:
    愚人节黑客以身试法 人民法院被挂马 狼人:
    微软:97%电子邮件属于垃圾邮件 狼人:
    4月3日 尤金.卡巴斯基在北大精彩演讲 狼人:
  • 原文地址:https://www.cnblogs.com/hhq80/p/1252737.html
Copyright © 2011-2022 走看看