组长为自己用flex做。组长为自家于是flex做。

而attachCamera(null),camera =
null之类,关不掉说明有遗漏

一个页面点左按钮,另一个页面点右按钮,再允许使用摄像头就是可以了

4:flex取值可以于后台用长途对象+事件监听取,也可以为此import导入ExternalInterface后因故ExternalInterface.call(“test”)直接调外部的js方法。

 1 <%@ page language="java"contentType="text/html; charset=UTF-8"  
 2     pageEncoding="UTF-8"%>  
 3 <%@taglib uri="FlexTagLib"prefix="mm"%>  
 4 <!DOCTYPE html PUBLIC "-//W3C//DTDHTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  
 5 <html>  
 6 <head>  
 7 <meta http-equiv="Content-Type"content="text/html; charset=UTF-8">  
 8 <title>心理咨询</title>  
 9 <style type="text/css">  
10 </style>  
11 <script type="text/javascript">
12 
13 </script>
14 </head>  
15 <body>  
16 <div id="chatPanel">
17     <mm:mxml source="../mxml/patient.mxml" width="500" height="380">  
18     </mm:mxml>
19 </div>
20 </body>  
21 </html> 

连接red5地址自主修改,rtmp://10.250.196.113/oflaDemo

以实施进度的干,我管初始化连接在了myFlex_resultHandler(event)里,保证收获到价值后又初始化

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <service id="remoting-service" 
 3     class="flex.messaging.services.RemotingService">
 4 
 5     <adapters>
 6         <adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter" default="true"/>
 7     </adapters>
 8 
 9     <default-channels>
10         <channel ref="my-amf"/>
11     </default-channels>
12     
13     <destination id="mytest">
14         <properties>
15             <source>test.Accptech</source>
16         </properties>
17     </destination>
18 
19 </service>

以下是参考资料部分:

以流名称写死了每次用需要以red5里stream文件夹脏文件清空

 

打开两独http://localhost:8088/flexweb/jsp/test.jsp,一个作为医生端,一个作为病人端,注意端口

remoting-config.xml

因实施进度的关联,我拿初始化连接在了myFlex_resultHandler(event)里,保证得到价值后又初始化

巧实习几只月,最近若是开一个视频聊天的效应,组长为我于是flex做。虽然是蛮老的技能,资料啊不翼而飞,但要努力去举行了。真正做了之后发现倒没有设想中的不便,主要就baidu、整理、分析、实验。

初始化时调用initValue,根据远程对象由后台取值(因为凡demo所以写很了),remoting-config.xml中安排

今凡片端都是友善

上传下载流是根据流的名的,red5的流保存在stream文件夹里

2:需要拿red5和blazeds的老三个war包拷贝到tomcat服务器webapp下。

test.jsp

http://blog.csdn.net/dianfusoft/article/details/8062930 flex嵌入jsp

 1 <%@ page language="java"contentType="text/html; charset=UTF-8"  
 2     pageEncoding="UTF-8"%>  
 3 <!DOCTYPE html PUBLIC "-//W3C//DTDHTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  
 4 <html>  
 5 <head>  
 6 <meta http-equiv="Content-Type"content="text/html; charset=UTF-8">  
 7 <title>测试</title>  
 8 <style type="text/css">  
 9 </style>  
10 <script type="text/javascript">
11 function bo(){
12     window.open('doctor.jsp','心理咨询','width=530,height=435,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no');
13 }
14 function po(){
15     window.open('patient.jsp','心理咨询','width=530,height=435,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no');
16 }
17 </script>
18 </head>  
19 <body>  
20 <div style="width:600px;height:500px">
21     <input type="button" value="视频聊天-医生" onclick="bo()"/>
22     <input type="button" value="视频聊天-病人" onclick="po()"/>
23 </div>
24 </body>  
25 </html> 

持续代码主要看注释吧,毕竟还算是详细

谷歌浏览器样子还不易,ie有点丑

demo环境:flex4.6 64位,tomcat6,myeclipse 10 64位,chrome。

 

test.jsp

remoting-config.xml

连接red5地址自主修改,rtmp://10.250.196.113/oflaDemo

patient.jsp

开辟两只http://localhost:8088/flexweb/jsp/test.jsp,一个作为医生端,一个作为病人端,注意端口

代码有即交此结束,测试步骤:

http://jingyan.baidu.com/article/495ba841f56c2738b30ede9f.html
flex插件安装

3:三单链接里之东西组成后安排文件或者重名,如web.xml,需挑出各自的一对组成起来。

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <service id="remoting-service" 
 3     class="flex.messaging.services.RemotingService">
 4 
 5     <adapters>
 6         <adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter" default="true"/>
 7     </adapters>
 8 
 9     <default-channels>
10         <channel ref="my-amf"/>
11     </default-channels>
12     
13     <destination id="mytest">
14         <properties>
15             <source>test.Accptech</source>
16         </properties>
17     </destination>
18 
19 </service>

2:需要以red5和blazeds的老三只war包拷贝到tomcat服务器webapp下。

http://wenku.baidu.com/view/46367d126c175f0e7cd137ba.html
flex整合myeclipse

 

上传下载流是根据流的讳的,red5的流保存在stream文件夹里

图片 1

代码有就是顶这结束,测试步骤:

以下是参考资料部分:

  1 <?xml version="1.0" encoding="utf-8"?>
  2 <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  3                 xmlns:fx="http://ns.adobe.com/mxml/2006"
  4                 layout="absolute"
  5                 backgroundColor="white"
  6                 initialize="initValue();">    
  7     <mx:RemoteObject id="myFlex" destination="mytest">
  8         <mx:method name="getMa" result="myFlex_resultHandler(event)"/>
  9     </mx:RemoteObject>
 10     <mx:Script>
 11         <![CDATA[    
 12             import mx.controls.Alert;
 13             import mx.rpc.events.ResultEvent;
 14             import flash.external.ExternalInterface;
 15             //定义一个连接
 16             public var netConnection:NetConnection; 
 17             //定义远程视频
 18             public var remoteVideo:Video;        
 19             //定义本地视频流  
 20             public var outStream:NetStream = null;
 21             public var netStreamName:String;
 22             //定义远程视频流
 23             public var remoteStream:NetStream = null;
 24             public var remoteStreamName:String;
 25             //定义一个摄像头  
 26             public var camera:Camera;  
 27             //定义一个麦克风  
 28             public var microphone:Microphone;      
 29             
 30             //rtmp服务器url
 31             private var rtmpUrl:String = "rtmp://10.250.196.113/oflaDemo";
 32             //定义帧数
 33             public var keyFrameInterval:int = 48;
 34             //播放速率
 35             public var keyFps:int = 8;
 36             public var keyRate:int = 10;
 37             public var keyQuality:int = 85;
 38             public var bufferTime:int = 500;
 39             public var encodeType:int = 2;
 40             public var gain:int = 60;    
 41             
 42             protected function myFlex_resultHandler(event:ResultEvent):void{
 43                 var ma:Object = event.result as Object;
 44                 netStreamName = ma.doctor as String;
 45                 remoteStreamName = ma.patient as String;            
 46                 initConnection();
 47             }        
 48             
 49             public function initValue():void{ 
 50                 //调用外部js方法
 51                 //Alert.show(ExternalInterface.call("test").b as String);
 52                 myFlex.getMa();
 53             }     
 54             
 55             public function initConnection():void{  
 56                 //初始化连接  
 57                 netConnection = new NetConnection();             
 58                 //为连接添加状态监听器  
 59                 netConnection.addEventListener(NetStatusEvent.NET_STATUS,netStatusHandler);
 60                 //为连接添加安全错误监听器  
 61                 netConnection.addEventListener(SecurityErrorEvent.SECURITY_ERROR,securityErrorHandler); 
 62                 //连接到服务器  
 63                 netConnection.connect(rtmpUrl);
 64             } 
 65             
 66             private function netStatusHandler(event:NetStatusEvent):void{
 67                 if (event.info.code == "NetConnection.Connect.Success"){
 68                     //本地输出流
 69                     outStream = new NetStream(netConnection);  
 70                     remoteStream = new NetStream(netConnection);
 71                     //得到当前摄像头
 72                     camera = Camera.getCamera();
 73                     //当前摄像头可用
 74                     if(camera){        
 75                         //设置摄像头参数
 76                         camera.setMode(480,360,(Number(keyFps)));
 77                         camera.setQuality(480*360*keyFps/8,keyQuality);
 78                         camera.setKeyFrameInterval(keyFrameInterval);    
 79                         //得到当前麦克风
 80                         microphone = Microphone.getMicrophone();
 81                         //设置麦克风
 82                         //microphone.rate = keyRate;
 83                         //microphone.setUseEchoSuppression(true);
 84                         doIt();
 85                     }else{
 86                         Alert.show("没有找到摄像头");
 87                         return;
 88                     }
 89                 }else{
 90                     Alert.show("连接服务器失败!");
 91                 }    
 92             }  
 93             
 94             private function securityErrorHandler(event:SecurityErrorEvent):void{   
 95                 Alert.show("securityErrorHandler: " + event);  
 96             }             
 97             
 98             public function doIt():void{    
 99                 //本地视频流获取摄像头和麦克风
100                 outStream.attachCamera(camera);  
101                 outStream.attachAudio(microphone);                        
102                 //本地视频流上传
103                 outStream.publish(netStreamName,"record");
104                 
105                 //得到远程流
106                 remoteStream.play(remoteStreamName);
107                 //根据远程流获取视频
108                 remoteVideo = new Video();
109                 remoteVideo.attachNetStream(remoteStream);
110                 remoteVideo.width = 480;
111                 remoteVideo.height = 360;
112                 
113                 //将视频放到控件上
114                 itsVideo.addChild(remoteVideo);
115                 //本地视频播放
116                 myVideo.attachCamera(camera);                        
117             }    
118                 
119         ]]>
120     </mx:Script>
121     <mx:TitleWindow id="p" headerHeight="8" x="0" y="0" width="500" height="380" layout="absolute">
122         <mx:VideoDisplay id="itsVideo" width="480" height="360"/>
123         <mx:VideoDisplay x="360" y="270" id="myVideo" width="120" height="90"/>
124     </mx:TitleWindow>
125 </mx:Application>
patient.mxml

  1 <?xml version="1.0" encoding="utf-8"?>
  2 <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  3                 xmlns:fx="http://ns.adobe.com/mxml/2006"
  4                 layout="absolute"
  5                 backgroundColor="white"
  6                 initialize="initValue();">    
  7     <mx:RemoteObject id="myFlex" destination="mytest">
  8         <mx:method name="getMa" result="myFlex_resultHandler(event)"/>
  9     </mx:RemoteObject>
 10     <mx:Script>
 11         <![CDATA[    
 12             import mx.controls.Alert;
 13             import mx.rpc.events.ResultEvent;
 14             //定义一个连接
 15             public var netConnection:NetConnection; 
 16             //定义远程视频
 17             public var remoteVideo:Video;        
 18             //定义本地视频流  
 19             public var outStream:NetStream = null;
 20             public var netStreamName:String;
 21             //定义远程视频流
 22             public var remoteStream:NetStream = null;
 23             public var remoteStreamName:String;
 24             //定义一个摄像头  
 25             public var camera:Camera;  
 26             //定义一个麦克风  
 27             public var microphone:Microphone;      
 28             
 29             //rtmp服务器url
 30             private var rtmpUrl:String = "rtmp://10.250.196.113/oflaDemo";
 31             //定义帧数
 32             public var keyFrameInterval:int = 48;
 33             //播放速率
 34             public var keyFps:int = 8;
 35             public var keyRate:int = 10;
 36             public var keyQuality:int = 85;
 37             public var bufferTime:int = 500;
 38             public var encodeType:int = 2;
 39             public var gain:int = 60;    
 40             
 41             protected function myFlex_resultHandler(event:ResultEvent):void{
 42                 var ma:Object = event.result as Object;
 43                 netStreamName = ma.patient as String;
 44                 remoteStreamName = ma.doctor as String;            
 45                 initConnection();
 46             }    
 47             
 48             public function initValue():void{  
 49                 myFlex.getMa();
 50             }                 
 51             
 52             public function initConnection():void{  
 53                 //初始化连接  
 54                 netConnection = new NetConnection();             
 55                 //为连接添加状态监听器  
 56                 netConnection.addEventListener(NetStatusEvent.NET_STATUS,netStatusHandler);
 57                 //为连接添加安全错误监听器  
 58                 netConnection.addEventListener(SecurityErrorEvent.SECURITY_ERROR,securityErrorHandler); 
 59                 //连接到服务器  
 60                 netConnection.connect(rtmpUrl);
 61             } 
 62             
 63             private function netStatusHandler(event:NetStatusEvent):void{
 64                 if (event.info.code == "NetConnection.Connect.Success"){
 65                     //本地输出流
 66                     outStream = new NetStream(netConnection);  
 67                     remoteStream = new NetStream(netConnection);                    
 68                     //得到当前摄像头
 69                     camera = Camera.getCamera();
 70                     //当前摄像头可用
 71                     if(camera){        
 72                         //设置摄像头参数
 73                         camera.setMode(480,360,(Number(keyFps)));
 74                         camera.setQuality(480*360*keyFps/8,keyQuality);
 75                         camera.setKeyFrameInterval(keyFrameInterval);    
 76                         //得到当前麦克风
 77                         microphone = Microphone.getMicrophone();
 78                         //设置麦克风
 79                         //microphone.rate = keyRate;
 80                         //microphone.setUseEchoSuppression(true);    
 81                         doIt();
 82                     }else{
 83                         Alert.show("没有找到摄像头");
 84                         return;
 85                     }
 86                 }else{
 87                     Alert.show("连接服务器失败!");
 88                 }    
 89             }  
 90             
 91             private function securityErrorHandler(event:SecurityErrorEvent):void{   
 92                 Alert.show("securityErrorHandler: " + event);  
 93             }             
 94             
 95             public function doIt():void{            
 96                 //本地视频流获取摄像头和麦克风
 97                 outStream.attachCamera(camera);  
 98                 outStream.attachAudio(microphone);                        
 99                 //本地视频流上传
100                 outStream.publish(netStreamName,"record");
101                 
102                 //得到远程流
103                 remoteStream.play(remoteStreamName);
104                 //根据远程流获取视频
105                 remoteVideo = new Video();
106                 remoteVideo.attachNetStream(remoteStream);
107                 remoteVideo.width = 480;
108                 remoteVideo.height = 360;
109 
110                 //将视频放到控件上
111                 itsVideo.addChild(remoteVideo);
112                 //本地视频播放
113                 myVideo.attachCamera(camera);                            
114             }    
115                 
116         ]]>
117     </mx:Script>
118     <mx:TitleWindow id="p" headerHeight="8" x="0" y="0" width="500" height="380" layout="absolute">
119         <mx:VideoDisplay id="itsVideo" width="480" height="360"/>
120         <mx:VideoDisplay x="360" y="270" id="myVideo" width="120" height="90"/>
121     </mx:TitleWindow>
122 </mx:Application>

doctor.jsp

4:flex取值可以于后台用长途对象+事件监听取,也可以为此import导入ExternalInterface后因故ExternalInterface.call(“test”)直接调外部的js方法。

抱到价值一个当本土流名字,一个作长途流名字,另一样端就是倒一下,其余的相同

以下是代码:

 1 <%@ page language="java"contentType="text/html; charset=UTF-8"  
 2     pageEncoding="UTF-8"%>  
 3 <%@taglib uri="FlexTagLib"prefix="mm"%>  
 4 <!DOCTYPE html PUBLIC "-//W3C//DTDHTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  
 5 <html>  
 6 <head>  
 7 <meta http-equiv="Content-Type"content="text/html; charset=UTF-8">  
 8 <title>心理咨询</title>  
 9 <style type="text/css">  
10 </style>  
11 <script type="text/javascript">
12     function test(){
13         return {a:'yes',b:'no'};
14     }
15 </script>
16 </head>  
17 <body>  
18 <div id="chatPanel">
19     <mm:mxml source="../mxml/doctor.mxml" width="500" height="380">  
20     </mm:mxml>
21 </div>
22 </body>  
23 </html> 

 

以下是代码:

只顾有:

图片 2

 1 <%@ page language="java"contentType="text/html; charset=UTF-8"  
 2     pageEncoding="UTF-8"%>  
 3 <%@taglib uri="FlexTagLib"prefix="mm"%>  
 4 <!DOCTYPE html PUBLIC "-//W3C//DTDHTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  
 5 <html>  
 6 <head>  
 7 <meta http-equiv="Content-Type"content="text/html; charset=UTF-8">  
 8 <title>心理咨询</title>  
 9 <style type="text/css">  
10 </style>  
11 <script type="text/javascript">
12     function test(){
13         return {a:'yes',b:'no'};
14     }
15 </script>
16 </head>  
17 <body>  
18 <div id="chatPanel">
19     <mm:mxml source="../mxml/doctor.mxml" width="500" height="380">  
20     </mm:mxml>
21 </div>
22 </body>  
23 </html> 

注意有:

 1 <%@ page language="java"contentType="text/html; charset=UTF-8"  
 2     pageEncoding="UTF-8"%>  
 3 <!DOCTYPE html PUBLIC "-//W3C//DTDHTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  
 4 <html>  
 5 <head>  
 6 <meta http-equiv="Content-Type"content="text/html; charset=UTF-8">  
 7 <title>测试</title>  
 8 <style type="text/css">  
 9 </style>  
10 <script type="text/javascript">
11 function bo(){
12     window.open('doctor.jsp','心理咨询','width=530,height=435,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no');
13 }
14 function po(){
15     window.open('patient.jsp','心理咨询','width=530,height=435,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no');
16 }
17 </script>
18 </head>  
19 <body>  
20 <div style="width:600px;height:500px">
21     <input type="button" value="视频聊天-医生" onclick="bo()"/>
22     <input type="button" value="视频聊天-病人" onclick="po()"/>
23 </div>
24 </body>  
25 </html> 

而今凡是鲜端都是自己

苟attachCamera(null),camera =
null之类,关不丢掉说明有脱

5:flex嵌入jsp只能用flex3,所以语法必须用flex3的语法,即mx标签,嵌入无需安装flex(不过编写的时刻没语法提示)。

doctor.jsp

http://jingyan.baidu.com/article/495ba841f56c2738b30ede9f.html
flex插件安装

5:flex嵌入jsp只能用flex3,所以语法必须用flex3的语法,即mx标签,嵌入无需安装flex(不过编写的上没语法提示)。

  1 <?xml version="1.0" encoding="utf-8"?>
  2 <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  3                 xmlns:fx="http://ns.adobe.com/mxml/2006"
  4                 layout="absolute"
  5                 backgroundColor="white"
  6                 initialize="initValue();">    
  7     <mx:RemoteObject id="myFlex" destination="mytest">
  8         <mx:method name="getMa" result="myFlex_resultHandler(event)"/>
  9     </mx:RemoteObject>
 10     <mx:Script>
 11         <![CDATA[    
 12             import mx.controls.Alert;
 13             import mx.rpc.events.ResultEvent;
 14             import flash.external.ExternalInterface;
 15             //定义一个连接
 16             public var netConnection:NetConnection; 
 17             //定义远程视频
 18             public var remoteVideo:Video;        
 19             //定义本地视频流  
 20             public var outStream:NetStream = null;
 21             public var netStreamName:String;
 22             //定义远程视频流
 23             public var remoteStream:NetStream = null;
 24             public var remoteStreamName:String;
 25             //定义一个摄像头  
 26             public var camera:Camera;  
 27             //定义一个麦克风  
 28             public var microphone:Microphone;      
 29             
 30             //rtmp服务器url
 31             private var rtmpUrl:String = "rtmp://10.250.196.113/oflaDemo";
 32             //定义帧数
 33             public var keyFrameInterval:int = 48;
 34             //播放速率
 35             public var keyFps:int = 8;
 36             public var keyRate:int = 10;
 37             public var keyQuality:int = 85;
 38             public var bufferTime:int = 500;
 39             public var encodeType:int = 2;
 40             public var gain:int = 60;    
 41             
 42             protected function myFlex_resultHandler(event:ResultEvent):void{
 43                 var ma:Object = event.result as Object;
 44                 netStreamName = ma.doctor as String;
 45                 remoteStreamName = ma.patient as String;            
 46                 initConnection();
 47             }        
 48             
 49             public function initValue():void{ 
 50                 //调用外部js方法
 51                 //Alert.show(ExternalInterface.call("test").b as String);
 52                 myFlex.getMa();
 53             }     
 54             
 55             public function initConnection():void{  
 56                 //初始化连接  
 57                 netConnection = new NetConnection();             
 58                 //为连接添加状态监听器  
 59                 netConnection.addEventListener(NetStatusEvent.NET_STATUS,netStatusHandler);
 60                 //为连接添加安全错误监听器  
 61                 netConnection.addEventListener(SecurityErrorEvent.SECURITY_ERROR,securityErrorHandler); 
 62                 //连接到服务器  
 63                 netConnection.connect(rtmpUrl);
 64             } 
 65             
 66             private function netStatusHandler(event:NetStatusEvent):void{
 67                 if (event.info.code == "NetConnection.Connect.Success"){
 68                     //本地输出流
 69                     outStream = new NetStream(netConnection);  
 70                     remoteStream = new NetStream(netConnection);
 71                     //得到当前摄像头
 72                     camera = Camera.getCamera();
 73                     //当前摄像头可用
 74                     if(camera){        
 75                         //设置摄像头参数
 76                         camera.setMode(480,360,(Number(keyFps)));
 77                         camera.setQuality(480*360*keyFps/8,keyQuality);
 78                         camera.setKeyFrameInterval(keyFrameInterval);    
 79                         //得到当前麦克风
 80                         microphone = Microphone.getMicrophone();
 81                         //设置麦克风
 82                         //microphone.rate = keyRate;
 83                         //microphone.setUseEchoSuppression(true);
 84                         doIt();
 85                     }else{
 86                         Alert.show("没有找到摄像头");
 87                         return;
 88                     }
 89                 }else{
 90                     Alert.show("连接服务器失败!");
 91                 }    
 92             }  
 93             
 94             private function securityErrorHandler(event:SecurityErrorEvent):void{   
 95                 Alert.show("securityErrorHandler: " + event);  
 96             }             
 97             
 98             public function doIt():void{    
 99                 //本地视频流获取摄像头和麦克风
100                 outStream.attachCamera(camera);  
101                 outStream.attachAudio(microphone);                        
102                 //本地视频流上传
103                 outStream.publish(netStreamName,"record");
104                 
105                 //得到远程流
106                 remoteStream.play(remoteStreamName);
107                 //根据远程流获取视频
108                 remoteVideo = new Video();
109                 remoteVideo.attachNetStream(remoteStream);
110                 remoteVideo.width = 480;
111                 remoteVideo.height = 360;
112                 
113                 //将视频放到控件上
114                 itsVideo.addChild(remoteVideo);
115                 //本地视频播放
116                 myVideo.attachCamera(camera);                        
117             }    
118                 
119         ]]>
120     </mx:Script>
121     <mx:TitleWindow id="p" headerHeight="8" x="0" y="0" width="500" height="380" layout="absolute">
122         <mx:VideoDisplay id="itsVideo" width="480" height="360"/>
123         <mx:VideoDisplay x="360" y="270" id="myVideo" width="120" height="90"/>
124     </mx:TitleWindow>
125 </mx:Application>
patient.mxml

  1 <?xml version="1.0" encoding="utf-8"?>
  2 <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  3                 xmlns:fx="http://ns.adobe.com/mxml/2006"
  4                 layout="absolute"
  5                 backgroundColor="white"
  6                 initialize="initValue();">    
  7     <mx:RemoteObject id="myFlex" destination="mytest">
  8         <mx:method name="getMa" result="myFlex_resultHandler(event)"/>
  9     </mx:RemoteObject>
 10     <mx:Script>
 11         <![CDATA[    
 12             import mx.controls.Alert;
 13             import mx.rpc.events.ResultEvent;
 14             //定义一个连接
 15             public var netConnection:NetConnection; 
 16             //定义远程视频
 17             public var remoteVideo:Video;        
 18             //定义本地视频流  
 19             public var outStream:NetStream = null;
 20             public var netStreamName:String;
 21             //定义远程视频流
 22             public var remoteStream:NetStream = null;
 23             public var remoteStreamName:String;
 24             //定义一个摄像头  
 25             public var camera:Camera;  
 26             //定义一个麦克风  
 27             public var microphone:Microphone;      
 28             
 29             //rtmp服务器url
 30             private var rtmpUrl:String = "rtmp://10.250.196.113/oflaDemo";
 31             //定义帧数
 32             public var keyFrameInterval:int = 48;
 33             //播放速率
 34             public var keyFps:int = 8;
 35             public var keyRate:int = 10;
 36             public var keyQuality:int = 85;
 37             public var bufferTime:int = 500;
 38             public var encodeType:int = 2;
 39             public var gain:int = 60;    
 40             
 41             protected function myFlex_resultHandler(event:ResultEvent):void{
 42                 var ma:Object = event.result as Object;
 43                 netStreamName = ma.patient as String;
 44                 remoteStreamName = ma.doctor as String;            
 45                 initConnection();
 46             }    
 47             
 48             public function initValue():void{  
 49                 myFlex.getMa();
 50             }                 
 51             
 52             public function initConnection():void{  
 53                 //初始化连接  
 54                 netConnection = new NetConnection();             
 55                 //为连接添加状态监听器  
 56                 netConnection.addEventListener(NetStatusEvent.NET_STATUS,netStatusHandler);
 57                 //为连接添加安全错误监听器  
 58                 netConnection.addEventListener(SecurityErrorEvent.SECURITY_ERROR,securityErrorHandler); 
 59                 //连接到服务器  
 60                 netConnection.connect(rtmpUrl);
 61             } 
 62             
 63             private function netStatusHandler(event:NetStatusEvent):void{
 64                 if (event.info.code == "NetConnection.Connect.Success"){
 65                     //本地输出流
 66                     outStream = new NetStream(netConnection);  
 67                     remoteStream = new NetStream(netConnection);                    
 68                     //得到当前摄像头
 69                     camera = Camera.getCamera();
 70                     //当前摄像头可用
 71                     if(camera){        
 72                         //设置摄像头参数
 73                         camera.setMode(480,360,(Number(keyFps)));
 74                         camera.setQuality(480*360*keyFps/8,keyQuality);
 75                         camera.setKeyFrameInterval(keyFrameInterval);    
 76                         //得到当前麦克风
 77                         microphone = Microphone.getMicrophone();
 78                         //设置麦克风
 79                         //microphone.rate = keyRate;
 80                         //microphone.setUseEchoSuppression(true);    
 81                         doIt();
 82                     }else{
 83                         Alert.show("没有找到摄像头");
 84                         return;
 85                     }
 86                 }else{
 87                     Alert.show("连接服务器失败!");
 88                 }    
 89             }  
 90             
 91             private function securityErrorHandler(event:SecurityErrorEvent):void{   
 92                 Alert.show("securityErrorHandler: " + event);  
 93             }             
 94             
 95             public function doIt():void{            
 96                 //本地视频流获取摄像头和麦克风
 97                 outStream.attachCamera(camera);  
 98                 outStream.attachAudio(microphone);                        
 99                 //本地视频流上传
100                 outStream.publish(netStreamName,"record");
101                 
102                 //得到远程流
103                 remoteStream.play(remoteStreamName);
104                 //根据远程流获取视频
105                 remoteVideo = new Video();
106                 remoteVideo.attachNetStream(remoteStream);
107                 remoteVideo.width = 480;
108                 remoteVideo.height = 360;
109 
110                 //将视频放到控件上
111                 itsVideo.addChild(remoteVideo);
112                 //本地视频播放
113                 myVideo.attachCamera(camera);                            
114             }    
115                 
116         ]]>
117     </mx:Script>
118     <mx:TitleWindow id="p" headerHeight="8" x="0" y="0" width="500" height="380" layout="absolute">
119         <mx:VideoDisplay id="itsVideo" width="480" height="360"/>
120         <mx:VideoDisplay x="360" y="270" id="myVideo" width="120" height="90"/>
121     </mx:TitleWindow>
122 </mx:Application>

图片 3

 1 <%@ page language="java"contentType="text/html; charset=UTF-8"  
 2     pageEncoding="UTF-8"%>  
 3 <%@taglib uri="FlexTagLib"prefix="mm"%>  
 4 <!DOCTYPE html PUBLIC "-//W3C//DTDHTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  
 5 <html>  
 6 <head>  
 7 <meta http-equiv="Content-Type"content="text/html; charset=UTF-8">  
 8 <title>心理咨询</title>  
 9 <style type="text/css">  
10 </style>  
11 <script type="text/javascript">
12 
13 </script>
14 </head>  
15 <body>  
16 <div id="chatPanel">
17     <mm:mxml source="../mxml/patient.mxml" width="500" height="380">  
18     </mm:mxml>
19 </div>
20 </body>  
21 </html> 

patient.jsp

一个页面点左按钮,另一个页面点右按钮,再允许采取摄像头就是足以了

初始化时调用initValue,根据远程对象由后台取值(因为凡demo所以写很了),remoting-config.xml中布局

适实习几单月,最近如举行一个视频聊天的功用,组长为自身所以flex做。虽然是殊老的技能,资料也有失,但要努力去做了。真正做了今后发现倒没有设想中的难以,主要就baidu、整理、分析、实验。

因为流名称写好了历次用用拿red5里stream文件夹脏文件清空

自己这边因为是坐至jsp(jsp页面功能只有播放),直接关闭页面就好了

3:三只链接里之事物组成后安排文件或者重名,如web.xml,需挑出各自的片段组成起来。

图片 4

doctor.mxml

最着重之接触是要是想关闭摄像头、麦克风的言辞不能不管具有attach置为空

一连初始化initConnection里上加监听,监听到连年成后执行后续代码

偷懒只写了一个jsp,里面有有限单按钮图片 5

谷歌浏览器样子还对,ie有点丑

http://wenku.baidu.com/view/46367d126c175f0e7cd137ba.html
flex整合myeclipse

1:flex安装版本及myeclipse对联合,32号对32号,64各类对64各类,否则重装myeclipse(作死实验了一些不折不扣)。

 

csdn上传文书限制60m,而且直接提示资源名字怪,需要之资源自己搜一下

demo环境:flex4.6 64位,tomcat6,myeclipse 10 64位,chrome。

图片 6

doctor.mxml

本身这边为凡停放到jsp(jsp页面功能只有播放),直接关门页面就可了

连年初始化initConnection里添加监听,监听到连续成功后实行后续代码

图片 7

1:flex安装版本及myeclipse对共同,32各类对32各类,64各项对64各项,否则重装myeclipse(作死实验了几许整)。

不过着重之触发是要想关闭摄像头、麦克风的语不能不管拥有attach置为空

持续代码主要关押注释吧,毕竟还算详细

 

csdn上传文书限制60m,而且一直提示资源名字怪,需要的资源自己搜一下

获取到价值一个当作本土流名字,一个当作长途流名字,另一样端就是倒一下,其余的等同

http://blog.csdn.net/dianfusoft/article/details/8062930 flex嵌入jsp

偷懒只写了一个jsp,里面来星星点点只按钮图片 8

相关文章