- 浏览: 222521 次
- 性别:
- 来自: 海南海口
文章分类
- 全部博客 (114)
- java基础 (25)
- 设计模式 (6)
- css (1)
- js (2)
- jquery (5)
- flash as3.0 (3)
- lucene (2)
- tomcat (3)
- uml (0)
- struts2 (7)
- spring (0)
- sql (1)
- ejb3.0 (2)
- jbpm4 (1)
- webservices (1)
- linux (3)
- ajax (1)
- 面试 (1)
- flex (0)
- soa (0)
- oracle解锁 (5)
- 工具 (3)
- ext (3)
- 好的网址 (1)
- junit (2)
- jmx (2)
- encache (1)
- redis (1)
- 网站 (1)
- oracle重要的sql (1)
- web (3)
- hadoop (2)
- DB2 (1)
- ui (1)
- sybase (1)
- ue使用快捷键 (1)
- eclipse优化 (1)
- 前端优化用到的插件 (1)
- zookeeper (1)
- solr (1)
- hibernate (1)
- svn (1)
- resion (1)
- resin (1)
- maven (1)
- mysql (1)
- url (1)
- 通过HttpFileServer设置共享 可以通过http方式访问 (1)
- 非技术 (2)
- 营销 (1)
- ELK (3)
最新评论
-
it_xiaowu:
jqwerty_123 写道我的出同样的问题却是因为引入cxf ...
java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Ma -
繁星水:
实验证明可用,最后补充一下,可以不需要 set Package ...
axis根据wsdl生成java客户端代码 -
qq_16699317:
qq_16699317 写道求一份源代码,感激不尽。。。多谢了 ...
java博客系统 -
qq_16699317:
求一份源代码,感激不尽。。。多谢了
java博客系统 -
jqwerty_123:
我的出同样的问题却是因为引入cxf的时候jcl-over-sl ...
java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Ma
这些都是很久以前玩flash的时候写的,为了怕掉,不知道以后还用没有用,毕竟是自己写的很值的留念哦!所以发上来备份一下,同时给需要的一个小小帮助!
学了as3 就接着学了fms:做了一个视频交流系统;写了3个类!
videoChat.as
package {
import flash.display.*;
import flash.text.*;
import flash.net.*;
import flash.events.*;
import flash.errors.*;
import flash.system.*;
import fl.managers.StyleManager;
import flash.media.*;
import fl.controls.List;
import fl.data.DataProvider;
import fl.controls.TextArea;
public class videoChat extends Sprite {
public var IP:String;
public var fmsPath:String;
public var myNC:NetConnection;
public var myNS:NetStream;
private var mySubNS:NetStream;
public var userName:String;
public var mySO:SharedObject;
public var peopleArray:Array;
public var tmpName:String;
public var msg:String
public var now:Date;
private var myCam:Camera;
private var myMic:Microphone;
public function videoChat() {
init();
startConnect();
}
public function init() {
var myTF:TextFormat=new TextFormat();
myTF.size=12;
StyleManager.setStyle("textFormat",myTF);//不理解的代码
IP="127.0.0.1";//不理解的代码
fmsPath="rtmp://"+IP+"/videoChat";//不理解的代码
userName="guest"+int(Math.random()*1000);
userName1.text=userName;
userName2.text="所有人";
now=new Date();
peopleList.addEventListener(MouseEvent.CLICK,selectChatTo);
peopleList.addEventListener(MouseEvent.DOUBLE_CLICK,getVideo);
}
public function startConnect() {
myNC=new NetConnection;
myNC.client=this;
myNC.objectEncoding=ObjectEncoding.AMF3;
myNC.addEventListener(NetStatusEvent.NET_STATUS,netStatus);
myNC.addEventListener(AsyncErrorEvent.ASYNC_ERROR,asyncError);
myNC.addEventListener(SecurityErrorEvent.SECURITY_ERROR,securityError);
myNC.connect(fmsPath,userName);
}
public function netStatus(event:NetStatusEvent):void {
switch (event.info.code) {
case "NetConnection.Connect.Success" :
chatContent.htmlText+="连接成功";
setMySO();
sendBtn.addEventListener(MouseEvent.MOUSE_DOWN,sendMsgByMouse);
stage.addEventListener(KeyboardEvent.KEY_DOWN,sendMsgByKey);
publishStream();
break;
case "NetConnection.Connect.Failed" :
chatContent.htmlText+="连接失败";
break;
case "NetConnection.Connect.Rejected" :
chatContent.htmlText+=event.info.application.message;
break;
}
}
public function securityError(event:SecurityErrorEvent):void{
chatContent.htmlText+="安全性错误"}
public function setMySO():void{
mySO=SharedObject.getRemote("mySO",myNC.uri,false)
mySO.addEventListener(SyncEvent.SYNC,mySoSync)
mySO.connect(myNC)}
public function asyncError(event:AsyncErrorEvent):void{}
public function mySoSync(e:SyncEvent):void{
peopleArray=new Array
for (var tmp in mySO.data){
peopleArray.push(tmp)}
var tmpDP:DataProvider=new DataProvider
for(var i=0;i<peopleArray.length;i++){
tmpName=peopleArray[i]
tmpDP.addItem({label:tmpName})}
tmpDP.sortOn("label")//很有可能有错
tmpDP.addItemAt({label:"所有人"},0)
peopleList.dataProvider=tmpDP
}
public function sendMsgByKey(event:KeyboardEvent):void{
if(event.keyCode==13){
sendMsg()}}
public function sendMsgByMouse(event:MouseEvent):void{
sendMsg()}
public function sendMsg():void{
if(willSendMsg.length>0){
if(userName2.text==userName1.text){
chatContent.htmlText+="你不能对你自己发言"+"\n"
chatContent.verticalScrollPosition=chatContent.maxVerticalScrollPosition}
else {
var allpeople:Array=new Array
for(var i=0;i<peopleList.length;i++){
if(peopleList.getItemAt(i).label!="所有人"&&peopleList.getItemAt(i).label!=userName1.text){
allpeople.push(peopleList.getItemAt(i).label)}}
msg="<font color='#ff0000'>"+userName1.text+"</font)"+"对"+"<font color='#ff0000'>"+userName2.text+"</font>"+"说"+"("+"<font color='#0000ff'>"+now.getHours()+":"+"</font>"+"\n"+willSendMsg.text+"\n"
if(userName2.text==null)
{
userName2.text="所有人"
}
myNC.call("msgFromClient",null,userName1.text,userName2.text,msg,allpeople)
chatContent.htmlText+=msg
chatContent.verticalScrollPosition=chatContent.maxVerticalScrollPosition
willSendMsg.text=""
}}}
public function msgFromSrvr(msg){
trace(msg)
chatContent.htmlText+=msg
chatContent.verticalScrollPosition=chatContent.maxVerticalScrollPosition}
private function selectChatTo(event:MouseEvent):void{
userName2.text=peopleList.selectedItem.label}
private function publishStream():void{
myCam=Camera.getCamera()
myMic=Microphone.getMicrophone()
liveVideo.attachCamera(myCam)
myNS=new NetStream(myNC)
myNS.client=this
myNS.addEventListener(NetStatusEvent.NET_STATUS,netStatus)
myNS.addEventListener(AsyncErrorEvent.ASYNC_ERROR,asyncError)
myNS.attachAudio(myMic)
myNS.attachCamera(myCam)
myNS.publish(userName1.text,"live")
}
private function getVideo(event:MouseEvent):void{
if(userName2.text!=userName1.text){
whoseVideo.text=userName2.text+"的视频 "
mySubNS=new NetStream(myNC)
mySubNS.client=this
mySubNS.addEventListener(NetStatusEvent.NET_STATUS,netStatus)
mySubNS.addEventListener(AsyncErrorEvent.ASYNC_ERROR,asyncError)//这个函数不是很清楚
liveVideo.attachNetStream(mySubNS)
mySubNS.play(userName2.text)}
else{
mySubNS.close()
liveVideo.clear()
whoseVideo.text="我的视频"
liveVideo.attachCamera(myCam)}}
}
}
Myself.as
package{
import flash.display.Sprite
import flash.events.MouseEvent
import flash.net.ObjectEncoding
import flash.net.NetConnection
import flash.net.NetStream
import flash.text.TextField
import fl.controls.List
public class extends Myself extends Sprite{
private var myNC:NetConnection
private var myNS:NetStream
private var userName1:String
private var userName2:String
public function Myself(){
init()
started()}
public function init(){
}}}
main.asc
application.onAppStart=function(){
trace("程序已启动")
list=new Object()
application.mySO=SharedObject.get("mySO",false)}
application.onConnect=function(newClient,userName){
trace("有新的用户连接:"+userName)
if(list[userName]==null){
list[userName]=newClient
newClient.userName=userName
this.acceptConnection(newClient)
application.mySO.setProperty(newClient.userName,userName)
newClient.msgFromClient=function(user1,user2,msg,allpeople){for(var i=0;i<allpeople.length;i++){
application.list[allpeople[i]].call("msgFromSrvr",null,msg)}}}
else {
var err=new Object()
err.message="对不起,该用户已存在"
application.rejectConnection(newClient,err)}}
application.onDisconnect=function(oldUser){
application.mySO.setProperty(oldUser.userName,null)
list[oldUser.userName]=null
delete list[oldUser.userName]}
学了as3 就接着学了fms:做了一个视频交流系统;写了3个类!
videoChat.as
package {
import flash.display.*;
import flash.text.*;
import flash.net.*;
import flash.events.*;
import flash.errors.*;
import flash.system.*;
import fl.managers.StyleManager;
import flash.media.*;
import fl.controls.List;
import fl.data.DataProvider;
import fl.controls.TextArea;
public class videoChat extends Sprite {
public var IP:String;
public var fmsPath:String;
public var myNC:NetConnection;
public var myNS:NetStream;
private var mySubNS:NetStream;
public var userName:String;
public var mySO:SharedObject;
public var peopleArray:Array;
public var tmpName:String;
public var msg:String
public var now:Date;
private var myCam:Camera;
private var myMic:Microphone;
public function videoChat() {
init();
startConnect();
}
public function init() {
var myTF:TextFormat=new TextFormat();
myTF.size=12;
StyleManager.setStyle("textFormat",myTF);//不理解的代码
IP="127.0.0.1";//不理解的代码
fmsPath="rtmp://"+IP+"/videoChat";//不理解的代码
userName="guest"+int(Math.random()*1000);
userName1.text=userName;
userName2.text="所有人";
now=new Date();
peopleList.addEventListener(MouseEvent.CLICK,selectChatTo);
peopleList.addEventListener(MouseEvent.DOUBLE_CLICK,getVideo);
}
public function startConnect() {
myNC=new NetConnection;
myNC.client=this;
myNC.objectEncoding=ObjectEncoding.AMF3;
myNC.addEventListener(NetStatusEvent.NET_STATUS,netStatus);
myNC.addEventListener(AsyncErrorEvent.ASYNC_ERROR,asyncError);
myNC.addEventListener(SecurityErrorEvent.SECURITY_ERROR,securityError);
myNC.connect(fmsPath,userName);
}
public function netStatus(event:NetStatusEvent):void {
switch (event.info.code) {
case "NetConnection.Connect.Success" :
chatContent.htmlText+="连接成功";
setMySO();
sendBtn.addEventListener(MouseEvent.MOUSE_DOWN,sendMsgByMouse);
stage.addEventListener(KeyboardEvent.KEY_DOWN,sendMsgByKey);
publishStream();
break;
case "NetConnection.Connect.Failed" :
chatContent.htmlText+="连接失败";
break;
case "NetConnection.Connect.Rejected" :
chatContent.htmlText+=event.info.application.message;
break;
}
}
public function securityError(event:SecurityErrorEvent):void{
chatContent.htmlText+="安全性错误"}
public function setMySO():void{
mySO=SharedObject.getRemote("mySO",myNC.uri,false)
mySO.addEventListener(SyncEvent.SYNC,mySoSync)
mySO.connect(myNC)}
public function asyncError(event:AsyncErrorEvent):void{}
public function mySoSync(e:SyncEvent):void{
peopleArray=new Array
for (var tmp in mySO.data){
peopleArray.push(tmp)}
var tmpDP:DataProvider=new DataProvider
for(var i=0;i<peopleArray.length;i++){
tmpName=peopleArray[i]
tmpDP.addItem({label:tmpName})}
tmpDP.sortOn("label")//很有可能有错
tmpDP.addItemAt({label:"所有人"},0)
peopleList.dataProvider=tmpDP
}
public function sendMsgByKey(event:KeyboardEvent):void{
if(event.keyCode==13){
sendMsg()}}
public function sendMsgByMouse(event:MouseEvent):void{
sendMsg()}
public function sendMsg():void{
if(willSendMsg.length>0){
if(userName2.text==userName1.text){
chatContent.htmlText+="你不能对你自己发言"+"\n"
chatContent.verticalScrollPosition=chatContent.maxVerticalScrollPosition}
else {
var allpeople:Array=new Array
for(var i=0;i<peopleList.length;i++){
if(peopleList.getItemAt(i).label!="所有人"&&peopleList.getItemAt(i).label!=userName1.text){
allpeople.push(peopleList.getItemAt(i).label)}}
msg="<font color='#ff0000'>"+userName1.text+"</font)"+"对"+"<font color='#ff0000'>"+userName2.text+"</font>"+"说"+"("+"<font color='#0000ff'>"+now.getHours()+":"+"</font>"+"\n"+willSendMsg.text+"\n"
if(userName2.text==null)
{
userName2.text="所有人"
}
myNC.call("msgFromClient",null,userName1.text,userName2.text,msg,allpeople)
chatContent.htmlText+=msg
chatContent.verticalScrollPosition=chatContent.maxVerticalScrollPosition
willSendMsg.text=""
}}}
public function msgFromSrvr(msg){
trace(msg)
chatContent.htmlText+=msg
chatContent.verticalScrollPosition=chatContent.maxVerticalScrollPosition}
private function selectChatTo(event:MouseEvent):void{
userName2.text=peopleList.selectedItem.label}
private function publishStream():void{
myCam=Camera.getCamera()
myMic=Microphone.getMicrophone()
liveVideo.attachCamera(myCam)
myNS=new NetStream(myNC)
myNS.client=this
myNS.addEventListener(NetStatusEvent.NET_STATUS,netStatus)
myNS.addEventListener(AsyncErrorEvent.ASYNC_ERROR,asyncError)
myNS.attachAudio(myMic)
myNS.attachCamera(myCam)
myNS.publish(userName1.text,"live")
}
private function getVideo(event:MouseEvent):void{
if(userName2.text!=userName1.text){
whoseVideo.text=userName2.text+"的视频 "
mySubNS=new NetStream(myNC)
mySubNS.client=this
mySubNS.addEventListener(NetStatusEvent.NET_STATUS,netStatus)
mySubNS.addEventListener(AsyncErrorEvent.ASYNC_ERROR,asyncError)//这个函数不是很清楚
liveVideo.attachNetStream(mySubNS)
mySubNS.play(userName2.text)}
else{
mySubNS.close()
liveVideo.clear()
whoseVideo.text="我的视频"
liveVideo.attachCamera(myCam)}}
}
}
Myself.as
package{
import flash.display.Sprite
import flash.events.MouseEvent
import flash.net.ObjectEncoding
import flash.net.NetConnection
import flash.net.NetStream
import flash.text.TextField
import fl.controls.List
public class extends Myself extends Sprite{
private var myNC:NetConnection
private var myNS:NetStream
private var userName1:String
private var userName2:String
public function Myself(){
init()
started()}
public function init(){
}}}
main.asc
application.onAppStart=function(){
trace("程序已启动")
list=new Object()
application.mySO=SharedObject.get("mySO",false)}
application.onConnect=function(newClient,userName){
trace("有新的用户连接:"+userName)
if(list[userName]==null){
list[userName]=newClient
newClient.userName=userName
this.acceptConnection(newClient)
application.mySO.setProperty(newClient.userName,userName)
newClient.msgFromClient=function(user1,user2,msg,allpeople){for(var i=0;i<allpeople.length;i++){
application.list[allpeople[i]].call("msgFromSrvr",null,msg)}}}
else {
var err=new Object()
err.message="对不起,该用户已存在"
application.rejectConnection(newClient,err)}}
application.onDisconnect=function(oldUser){
application.mySO.setProperty(oldUser.userName,null)
list[oldUser.userName]=null
delete list[oldUser.userName]}
相关推荐
as3+fms连线对战中国象棋,包含全部源程序。原文引自:http://bbs.haina2010.com
FMS+AS3.0多人聊天室源文件下载。
Flex+FMS写的视频聊天,在本机亲测通过。但唯一不足得是在别的机子上连接不成功。我也不知道为什么。望有才之士能完善。huzhaohui1992@qq.com 如能完善,请给我邮箱一份,在下感激不尽。
本例子用Flex3.0和FMS3.0共同开发视频会议!!是初学者的必备参考!!
asp+fms语音聊天室asp+fms语音聊天室
基于FLASH+XML+FMS的视频点播.pdf
Flash Media Live Encoder v3.0,FMS直播采集推送工具,直播系统必备。
基于thikphp加FMS 开发的 视频直播系统 。
通过flex 和 fms开发的一个简易的调用摄像头和音频录制的例子。亲测可以用的。需要本地搭建一个fms服务器,并在flex中填写好fms服务器地址即可使用
一个简单的聊天室供大家分享,基于FMS的AS3聊天室源代码
主要功能是从服务端以字节流的方式加载swf、图片、文本等文件,理论上讲可以用做swf文件...另外,以字节流加载本地swf或在本地共享对象中存取swf、图片、文本等文件,原理与这个例子相同,有兴趣的网友可以自己试一试。
flash+fms2视频聊天室-附带源码 源码在 html页面上有下载的超链接
本引擎QQ交流群:73944013 FLASH+php WEBGame 45度地图切换 多人游戏社区 FLASH人物行走 FLASH人物8方向寻路 在线聊天 (源码+fms服务端)开源项目 游戏截图: http://www.365tt1.com/ads/RGP/001.jpg ...
flash+fms游戏大厅房间源程序flash+fms游戏大厅房间源程序.rar
flash+FMS斗地主游戏源程序 吐血献出!
fms视频会议源代码,Flash + FMS
flash+FMS斗地主源程序,包含大厅、房间、聊天部分,每个房间可坐50桌。更多flash/flex源程序请登陆海纳论坛: http://bbs.haina2010.com
文章讲述了怎样搭建FMS系统,采集视频直播如何实现?风景直播系统如何实现?教育直播系统如何实现?幼儿园视频直播系统如何实现?交通直播系统如何实现?RTMP协议如何实现直播?无线安装插件的视频直播如何实现?看...
phpvod+fms4.5局域网视频点播系统搭建-附件资源
多人视频会议系统,基于FMS的,包含全部源码。