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>

  • 相关阅读:
    01Angular开发环境配置
    不再显示广告案例(php操作cookie)
    php操作 cookie
    JPush Android 推送如何区分开发、生产环境
    10 分钟实现一个自己的服务器监控器
    iOS 轻松使用 App 数据统计
    认识本质:黑天鹅、关键时刻与张小龙的产品观
    C# 服务端推送,十步十分钟,从注册到推送成功
    聊天界面-自适应文字
    极光推送的角标问题——让人又爱又恨的小红点
  • 原文地址:https://www.cnblogs.com/hhq80/p/1252737.html
Copyright © 2011-2022 走看看