视频聊天源码【旗舰版(上)】

<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" width="800" height="600" creationComplete="init()" minHeight="600"> <s:layout> <s:BasicLayout/> </s:layout> <fx:Style source="videoChat.css"/> <fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> </fx:Declarations> <fx:Script> <!--[CDATA[ import mx.collections.ArrayCollection; import mx.controls.Alert; import mx.controls.Text; import mx.events.CloseEvent; import mx.events.FlexEvent; import mx.events.VideoEvent; import mx.rpc.events.ResultEvent; import mx.rpc.http.HTTPService; import spark.components.TextArea; private var IP:String; private var redPath:String; private var nc:NetConnection; private var ns:NetStream; private var ns2:NetStream; private var cam:Camera private var mic:Microphone; private var listSO:SharedObject; private var msgSO:SharedObject; [Bindable] private var sendMsg:String; private var now:Date; private var userIDObj:Object; private var video:Video; private var currentChatFriend:String=null; private var currentUser:String=null; [Bindable] private var sizes:ArrayCollection=new ArrayCollection(new Array(6,8,10,12,14,15,16,18,20,22,24,25,28)); [Bindable] private var fonts:ArrayCollection=null; public const xmlUrl:String="MyFaces.xml"; [Bindable]private var faceList:ArrayCollection; private function findAllFonts():void{ fonts=new ArrayCollection(Font.enumerateFonts(true)); } //设置字体 private function setFont():void{ //sendmessage.setStyle("fontFamily",(ziti.selectedItem as Font).fontName); } private function init():void{ IP="192.168.1.100"; redPath="rtmp://"+IP+"/makeFriend"; nc=new NetConnection(); now=new Date(); main.visible=false; login.visible=true; findAllFonts(); changeRichTextEditor(); this.facespanel.visible=false; var service:HTTPService = new HTTPService(); service.url = xmlUrl; service.addEventListener(ResultEvent.RESULT, resultHandler); service.send(); facespanel.addEventListener(MouseEvent.ROLL_OUT,closePanel); } private function startConnect():void{ nc.addEventListener(NetStatusEvent.NET_STATUS,statusHandler); nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR,securityHandler); nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR,asyncHandler); nc.connect(redPath,username.text,userpwd.text); nc.client=this; } private function statusHandler(e:NetStatusEvent):void{ if(e.info.code=="NetConnection.Connect.Success"){ login.visible=false; main.visible=true; main.title="双击好友头像可以聊天!!"; this.width=680; setListSO(); setMsgSO(); currentUser=username.text; btnSend.addEventListener(MouseEvent.CLICK,sendBtnByClick); main.addEventListener(KeyboardEvent.KEY_DOWN,sendBtnByKey); } if(e.info.code=="NetConnection.Connect.Failed") { Alert.show("连接失败"); } if(e.info.code=="NetConnection.Connect.Closed") { Alert.show("服务器已经将您的连接关闭,请尝试重新连接!!!"); } } private function securityHandler(e:SecurityError):void{ // Alert.show("低调的安全沙箱错误"); } private function asyncHandler(e:AsyncErrorEvent):void{ // Alert.show("低调的异步错误"); } private function publishVideo():void{ this.width=800; this.friendList.visible=false; this.chatVideo.visible=true; ns=new NetStream(nc); cam=Camera.getCamera(); mic=Microphone.getMicrophone(); myVideo.attachCamera(cam); ns.client=this; // ns.addEventListener(NetStatusEvent.NET_STATUS,statusHandler); ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR,asyncHandler); ns.attachCamera(cam); ns.attachAudio(mic); ns.publish(currentUser,"live"); } private function setListSO():void{ listSO=SharedObject.getRemote("listSO",nc.uri,false); listSO.connect(nc); listSO.addEventListener(SyncEvent.SYNC,listSOSyncHandler); } private function setMsgSO():void{ msgSO = SharedObject.getRemote("msgSO", nc.uri, false); msgSO.addEventListener(SyncEvent.SYNC, msgSOSyncHandler); msgSO.connect(nc); } private function msgSOSyncHandler(e:SyncEvent):void{ for (var i in msgSO.data) { txtmessage.text =txtmessage.text+ msgSO.data[i]; } } private function listSOSyncHandler(e:SyncEvent):void{ showUserList(); } private function showUserList():void{ friendList.removeAllElements(); var la:Label=new Label(); la.text="在线好友"; la.height=30; la.styleName="labstyle"; friendList.addElement(la); for(var tmp in listSO.data) { var g:Group=new Group(); g.percentWidth=100; g.height=61; g.buttonMode=true; g.id=listSO.data[tmp].userName; var lab:Label=new Label(); lab.text=listSO.data[tmp].userName; lab.x=65; lab.y=32; var image:Image=new Image(); if(listSO.data[tmp].uimage==""||listSO.data[tmp].uimage==null){ image.source="images/boy.jpg"; image.width=44; image.height=44; }else{ image.source=listSO.data[tmp].uimage; } image.x=10; image.y=9; g.addElement(lab); g.addElement(image); g.doubleClickEnabled=true; g.alpha=0.9; g.addEventListener(MouseEvent.MOUSE_MOVE,groupMouserMove); g.addEventListener(MouseEvent.MOUSE_OUT,groupMouserOut); g.addEventListener(MouseEvent.DOUBLE_CLICK,updateChatTo); friendList.addElement(g); } } private function updateChatTo(e:Event):void{ var g:Group= e.currentTarget as Group currentChatFriend=g.id; main.title="您正与"+g.id+"聊天中"; } private function groupMouserMove(e:MouseEvent):void{ var g:Group=e.currentTarget as Group; g.alpha=1; } private function groupMouserOut(e:MouseEvent):void{ var g:Group=e.currentTarget as Group; g.alpha=0.9; } public function showFrendSP(chatFriend:String):void{ try{ video=new Video(); ns2=new NetStream(nc); ns2.addEventListener(AsyncErrorEvent.ASYNC_ERROR,asyncHandler); ns2.client=this; video.attachNetStream(ns2); video.width=288; video.height=218; friendVideo.addChild(video); ns2.play(chatFriend); friendVideo.play(); }catch(e:Error){ } } //关闭视频的时候 private function videoExit(e:Event):void{ this.width=680; ns2.close(); ns.close(); myVideo.close(); friendVideo.close(); this.friendList.visible=true; this.chatVideo.visible=false; if(_chatFrend!=null){ nc.call("exitVideo",null,currentUser,_chatFrend); } } public function exitVideo():void{ this.width=680; ns2.close(); ns.close(); myVideo.close(); friendVideo.close(); this.friendList.visible=true; this.chatVideo.visible=false; } private function setSize():void{ //this.sendmessage.textFlow.fontSize=zihao.selectedItem; //this.sendmessage.htmlText='<font size="'+zihao.selectedItem+'" >'+this.sendmessage.text+'</font>'; } private function sendBtnByClick(e:Event):void{ sendMsge(); } private function sendBtnByKey(e:KeyboardEvent):void{ if(e.keyCode==Keyboard.ENTER&&e.ctrlKey==true) { sendMsge(); } } private function sendErrorMessage(touser:String,mess:String):void{ nc.call("msgFromPrivate",null,mess,currentUser,touser); } private function sendMsge():void{ var mess:String=currentUser+" "+now.toTimeString()+"\r\n"+sendmessage.htmlText+"\r\n"; if(currentUser==currentChatFriend){ Alert.show("您不能与自己聊天,请重新更换聊天对象!!!","Soory"); return; } if(sendmessage.text==""){ Alert.show("发送信息不能为空!!!","Soory"); return ; } if(currentChatFriend==null){ Alert.show("请选择发送对象!!!","Soory"); return ; } if(currentChatFriend!=null){ nc.call("msgFromPrivate",null,mess,currentUser,currentChatFriend); sendmessage.text=""; txtmessage.htmlText+=mess; } } public function showLoginError():void{ Alert.show("您的账号已经在其他地方登陆,您将回到登录页面","soory"); nc.close(); } public function showMsgByPrivate (msg:String,from:String,to:String):void{ txtmessage.htmlText=txtmessage.htmlText+msg; } public function showfaceMsgByPrivate(msg:String,from:String,to:String):void{ this.txtmessage.htmlText+=msg; } private function sendClear(event:Event){ this.sendmessage.text=""; } private function requestSP():void{ if(chatVideo.visible){ Alert.show("您的视频正在连接中,请挂断之后再操作!","提示"); return; } if(currentUser==currentChatFriend){ Alert.show("您不能与自己进行视频聊天,你可以点击打开我的视频,让网友看见您的视频!","提示"); return; } if(currentChatFriend==null){ Alert.show("您没有选择视频聊天好友,您将会打开您的视频给所有网友观看","提示"); publishVideo(); return; } publishVideo(); nc.call("requestSP",null,currentUser,currentChatFriend); } private var _chatFrend:String; public function showSPRequest(chatFrend:String):void{ _chatFrend=chatFrend; Alert.show(chatFrend+"请求与您视频聊天","信息",Alert.YES|Alert.NO,this,alertHandel); } private function alertHandel(event:CloseEvent):void{ if(event.detail==Alert.YES){ currentChatFriend=_chatFrend; publishVideo(); friendVideo.toolTip="视频信息拉取中..."; showFrendSP(_chatFrend); nc.call("echoSPRequest",null,currentUser,_chatFrend); }else{ sendErrorMessage(_chatFrend,currentUser+"拒绝了您的视频邀请!\r\n"); txtmessage.text+="您拒绝了对方的视频请求!\r\n" } } private function resultHandler(event:ResultEvent):void{ faceList=event.result.faces.face; } private function showPanel():void{ if(currentUser==currentChatFriend){ Alert.show("您不能与自己聊天,请重新更换聊天对象!!!","Soory"); return; } if(currentChatFriend==null){ Alert.show("请选择发送对象!!!","Soory"); return ; } if(currentChatFriend!=null){ this.facespanel.visible=true; } } private function closePanel(e:Event):void{ this.facespanel.visible=false; } //用户选择图片的单击事件 private function imageclick(evt:Event):void { var img:Image=evt.currentTarget as Image; var idx:int=int(img.data); var msg:String=currentUser+" "+now.toTimeString()+'<img src="images/Face/'+idx+'.swf" mce_src="images/Face/'+idx+'.swf" />'+"\r\n"; nc.call("facemsgPrivate",null,msg,currentUser,currentChatFriend); sendmessage.text=""; txtmessage.htmlText+=msg+"\r\n"; closePanel(evt); } //滚动条自动滚动到最下面,方便用户看聊天记录 private function updateCompleteHandler(evt:FlexEvent):void { this.txtmessage.verticalScrollPosition=this.txtmessage.maxVerticalScrollPosition; } //改变RichTextEditor的布局 private function changeRichTextEditor():void{ sendmessage.linkTextInput.visible=false; sendmessage.bulletButton.visible=false; sendmessage.alignButtons.visible=false; sendmessage.fontFamilyCombo.x=6; sendmessage.fontFamilyCombo.y=-180; sendmessage.fontSizeCombo.x=145; sendmessage.fontSizeCombo.y=-180; sendmessage.toolBar2.x=200; sendmessage.toolBar2.y=-180; sendmessage.colorPicker.x=275; sendmessage.colorPicker.y=-180; sendmessage._RichTextEditor_VRule1.visible=false; sendmessage.fontFamilyCombo.selectedIndex=0; } ]]--> </fx:Script> <s:Panel id="login" title="欢迎您的访问" width="100%" height="100%" contentBackgroundColor="#F0F8FF"> <s:Label x="381" y="109" text="登 录" width="192" height="35" fontFamily="中易宋体" fontSize="25" verticalAlign="middle" textAlign="center" fontWeight="normal" fontStyle="normal"/> <s:Label x="353" y="167" text="用户名:" width="73" height="24" verticalAlign="middle" fontFamily="中易宋体" fontSize="16"/> <s:Label x="353" y="212" text="密 码:" width="73" height="24" verticalAlign="middle" fontFamily="中易宋体" fontSize="16"/> <s:TextInput id="username" x="446" y="168" width="154" textAlign="left" maxChars="18" contentBackgroundColor="#FFFFFF"/> <s:TextInput id="userpwd" x="445" y="214" width="154" textAlign="left" displayAsPassword="true" maxChars="18" contentBackgroundColor="#FFFFFF"/> <s:Button x="373" y="257" label="登录" id="btnsub" click="startConnect()" fontFamily="中易宋体"/> <s:Button x="501" y="257" label="取消" id="cancel" click="navigateToURL(new URLRequest('javascript:window.close()'),'_self')" fontFamily="中易宋体"/> </s:Panel> <s:Panel id="main" width="100%" height="100%" backgroundColor="#F0F8FF" contentBackgroundColor="#FFFFFF" chromeColor="#AFB5CF" cornerRadius="10" borderVisible="true"> <s:BorderContainer id="chatMain" width="475" height="100%" backgroundColor="#F0F8FF"> <mx:TextArea enabled="false" id="txtmessage" x="14" y="19" width="445" height="292" contentBackgroundColor="#FFFFFF" fontFamily="中易宋体" updateComplete="updateCompleteHandler(event)" accentColor="#FFFFFF" borderColor="#FFFFFF" chromeColor="#FFFFFF" /> <!--<s:TextArea id="sendmessage" x="14" y="355" width="445" height="145" contentBackgroundColor="#FFFFFF"/>--> <!--<mx:TextArea id="sendmessage" x="14" y="355" width="445" height="145" contentBackgroundColor="#FFFFFF"/>--> <mx:RichTextEditor id="sendmessage" x="14" y="355" width="100%" height="100%" contentBackgroundColor="#FFFFFF" headerHeight="5" borderColor="#F0F8FF" accentColor="#F0F8FF" backgroundAlpha="2.0" backgroundColor="#F0f8FF" borderAlpha="2.0" chromeColor="#F0F8FF" contentBackgroundAlpha="2.0" cornerRadius="0" disabledColor="#FCFCFC" dropShadowVisible="false" paddingRight="10"/> <s:Button id="btnSend" x="279" y="519" label="发送" fontFamily="中易宋体"/> <s:Button id="btnClear" x="374" y="519" label="清空" click="sendClear(event)" fontFamily="中易宋体"/> <!--<s:BorderContainer id="sub" width="445" height="40" x="14" y="314" backgroundColor="#F0F8FF">--> <mx:Image x="337" y="325" id="expression" source="@Embed('images/face.jpg')" toolTip="选择表情" buttonMode="true" autoLoad="true" width="24" height="24" scaleContent="false" click="showPanel()"/> <mx:Image x="375" y="325" source="@Embed('images/shipin.jpg')" id="shipin" buttonMode="true" width="22" height="22" click="requestSP()"/> <!--<s:ComboBox x="29" y="6" width="85" id="ziti" change="setFont()" labelField="fontName" dataProvider="{fonts}" contentBackgroundColor="#FFFFFF"/> <s:Label x="1" y="10" text="字体" id="zt" fontFamily="中易宋体" fontSize="14" /> <s:Label x="119" y="10" text="字号" fontFamily="中易宋体" fontSize="14" id="zh"/> <s:ComboBox x="147" y="6" width="49" id="zihao" dataProvider="{sizes}" change="setSize()" contentBackgroundColor="#FFFFFF"/> <mx:Image buttonMode="true" x="203" y="7" id="ct" width="22" height="22" source="@Embed('images/ct1.jpg')"/> <mx:Image buttonMode="true" x="230" y="7" height="22" width="22" id="xhx" source="@Embed('images/xhx1.jpg')"/> <mx:Image buttonMode="true" x="258" y="7" id="ys" source="@Embed('images/yanse1.jpg')" height="22" width="22"/>--> <!--</s:BorderContainer>--> </s:BorderContainer> <s:BorderContainer id="chatVideo" visible="false" width="43%" height="100%" backgroundColor="#F0F8FF" x="468" y="0"> <mx:VideoDisplay id="myVideo" width="288" height="217" x="21" y="276"/> <mx:VideoDisplay id="friendVideo" width="288" height="217" x="21" y="23"/> <s:Label x="29" y="523" text="视频连接中:" id="time" fontSize="14" fontFamily="中易宋体"/> <s:Button x="234" y="517" label="挂断" id="videoClose" fontSize="15" click="videoExit(event)" fontFamily="中易宋体"/> </s:BorderContainer> <s:VGroup id="friendList" x="495" y="0" width="190" height="100%" gap="0" contentBackgroundColor="#F0F8FF" chromeColor="#D88A8A"> <s:Label id="friendCount" text="在线人数:" width="100%" height="32" styleName="labstyle" fontFamily="中易宋体"/> <s:Group x="19" y="44" width="100%" height="61" id="detail1" chromeColor="#DF4848" buttonMode="true" color="#921F1F"> <mx:Image x="10" y="9" source="@Embed('images/boy.jpg')" width="44" height="44" id="photo1"/> <s:Label x="65" y="32" text="天涯海角" id="nicheng1" width="114" height="19" verticalAlign="middle" fontWeight="bold"/> </s:Group> </s:VGroup> </s:Panel> <mx:Panel id="facespanel" title="默认表情" x="40" y="80" width="487" height="310" cornerRadius="10" accentColor="#F6F1F1" borderVisible="true" dropShadowVisible="false" borderColor="#6CA6CD" borderAlpha="2.5" backgroundAlpha="10" backgroundColor="#FDFAFA" visible="false"> <mx:ToolBar width="485" > <mx:Repeater id="faceRep" dataProvider="{faceList}"> <mx:Image click="imageclick(event)" buttonMode="true" data="{faceRep.currentIndex}" toolTip="{faceRep.currentItem.tp}" source="{faceRep.currentItem.icon}" /> </mx:Repeater> </mx:ToolBar> </mx:Panel> </s:Application>

本版本只发上半部,严禁商业抄袭!!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
### 回答1: Shopwind旗舰版源码是一个开源电商平台解决方案,它集成了许多实用的功能,比如商品管理、订单管理、支付方式、物流管理等,可以帮助用户快速搭建自己的电商网站。Shopwind旗舰版源码不仅支持PC端,还支持手机端和微信小程序,能够满足不同终端访问的需求。同时,Shopwind旗舰版源码还可扩展性较高,基于其基础源码可以开发出更加定制化和个性化的功能,满足不同行业和用户的需求。此外,Shopwind旗舰版源码还提供了丰富的插件和模板库,提高了平台的可用性和美观性,让用户可以更便捷地搭建自己的电商平台。最后,在维护方面,Shopwind旗舰版源码提供了较为完善的技术支持和社群支持,有问题时可以及时得到解决。综上所述,Shopwind旗舰版源码是一个优秀的开源电商平台解决方案,可以帮助用户快速搭建稳定、高效、安全的电商网站。 ### 回答2: Shopwind是一款开源的电商平台,其中旗舰版是其功能最丰富的版本,包含了许多高级功能和性能优化。其源码可以帮助开发者快速搭建自己的电商平台,同时也可以根据需要定制功能。 Shopwind旗舰版源码包含了完整的后台管理系统和前端商城页面,支持多种支付方式和配送方式,可以轻松管理商品、订单、用户、运营活动等内容。此外,Shopwind旗舰版还提供了完整的API接口,方便开发者与其他系统进行集成。 Shopwind旗舰版源码使用PHP语言编写,采用MVC架构,具有较高的代码规范和可读性,也方便二次开发和维护。其代码开放、完整、清晰,拥有活跃的社区和完善的技术支持,开发者可以快速上手并快速开发电商网站。 最后,需要注意的是,使用Shopwind旗舰版源码需要一定的PHP和网站开发经验,以确保开发的安全性和稳定性。同时,开发者还需要为自己的网站做好安全性预防和维护工作,避免出现安全漏洞和问题。 ### 回答3: Shopwind旗舰版源码是一个开源的电商系统源码,采用PHP程序语言编写,同时使用了MySQL数据库技术。店长可以通过Shopwind旗舰版源码搭建一个功能丰富的电商平台,包括商品展示、订单管理、支付结算、客户服务等多个方面,提供给消费者一个简单、友好的购物体验。 Shopwind旗舰版源码的优点在于它开源、免费、简单、高效。任何人都可以使用它,并且可以根据自己的需要进行定制。同时,它采用了可扩展和模块化设计的架构,具有很好的可拓展性,可以支持更多的功能开发和模块的添加。最重要的是,它可以通过设计师和程序员的搭配,进行自主开发和设计,以及上线运营整个电商平台,从而帮助店家实现自己的网店营收。 总之,Shopwind旗舰版源码对于购买力较弱的中小店主和创业者来说,是一个非常好的选择。它既便宜又功能齐全,可以满足市场上大部分的电商运营需求。同时,Shopwind提供了完善的技术支持和社区交流平台,让用户可以得到及时的问题解决和经验分享,从而让他们更好地运营自己的电商平台。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值