FMS Case Development - Video chat room (c) [switch]

2010-12-25  来源:本站原创  分类:Flash  人气:126 

This paper describes the main content to use SharedObject to implement text chat and online chat user list, and the achievement of voice and video chat.

Previous article introduces the realization of user registration and login function, this paper introduces the user to register and log in after a successful development-related functions. Under the first analysis, users log in successfully to do four things:

1, to show their video to the chat interface (not very useful, to look up only)

2, publish your own video and voice data to the FMS server (the role of large, others are based on the data see you publish your video, etc.)

3, the basic information to their own writing, such as shared objects, to achieve a list of online users.

4, to achieve the target through the sharing of text chat (This article is just for demonstration, the actual development should make full use of Client-Server implementation between the method call)

OK, with the above analysis, the next step by step to achieve these functions. Show their video to the interface is very simple, in the past have used the related article to.

<!--< Br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware) <br /> http://www.CodeHighlighter.com/ <br /> <br /> -> private function displayCameraSelf ( ): void
{
/ / Show your own video
myCamera = Camera.getCamera ();
if (myCamera! = null)
{
this.twoVideo.attachCamera (myCamera);
}
else
{
Alert.okLabel = "OK";
Alert.show ("did not detect the video camera!", "Prompted");
}
}

Posted video data to the FMS is very simple, either through the NetConnection and NetStream to complete, should be noted that, in the release of the video stream when the video stream using the naming convention the user name, user name is what, he issued a video stream What name is called, other users to view video of his user name is named by his name to see the flow.

<!--< Br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware) <br /> http://www.CodeHighlighter.com/ <br /> <br /> -> private function onLoginRusult ( evt: ResultEvent): void
{
if (evt.result! = null)
{
/ / Show your own video
displayCameraSelf ();

/ / Connect FMS publish their own video streaming server
publishNc = new NetConnection ();
publishNc.connect ("rtmp: / / localhost / ChatRoom");
publishNc.addEventListener (NetStatusEvent.NET_STATUS, onNetStatusHandler);
publishNc.client = this;

playNc = new NetConnection ();
playNc.connect ("rtmp: / / localhost / ChatRoom");
playNc.addEventListener (NetStatusEvent.NET_STATUS, onPlayStatusHandler);
playNc.client = this;

so = SharedObject.getRemote ("ChatSO", publishNc.uri, false);
so.addEventListener (SyncEvent.SYNC, onSyncHandler);
so.connect (publishNc);
so.client = this;

userSO = SharedObject.getRemote ("UserSO", publishNc.uri, false);
userSO.connect (publishNc);
userSO.client = this;

UserName = myUserName = evt.result.UserName;
NickName = myNickName = evt.result.NickName;

/ / Add the current user to the shared object
var uarray: ArrayCollection;
var o: Object = new Object ();
o.UserName = myUserName;
o.NickName = myNickName;

if (userSO.data.UserList == null)
{
uarray = new ArrayCollection ();
}
else
{
uarray = userSO.data.UserList as ArrayCollection;

}
var temp: ArrayCollection = new ArrayCollection ();
convertArrayCollection (temp, uarray);
temp.addItem (o);
userSO.setProperty ("UserList", temp);

this.loginPanel.visible = false;
this.chatRoomPanel.visible = true;
ChatRoomViewStack.selectedChild = chatRoomPanel;
}
else
{
Alert.okLabel = "OK";
Alert.show ("Login failed!", "Prompted");
}
}

private function onNetStatusHandler (evt: NetStatusEvent): void
{
if (evt.info.code == "NetConnection.Connect.Success")
{
/ / Connection is successful then publish their own flow FMS
publishNs = new NetStream (publishNc);
publishNs.attachAudio (myMic);
publishNs.attachCamera (myCamera);
publishNs.client = this;
/ / User name as the video stream name, user name to connect directly to each other through the flow
publishNs.publish (myUserName, "live");
}
}

Default on the talk yourself and your only choice from the online users list and the corresponding user only person video chat, that is initialized to their connection to their video stream. Implementation code is as follows:

<!--< Br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware) <br /> http://www.CodeHighlighter.com/ <br /> <br /> -> private function onPlayStatusHandler ( evt: NetStatusEvent): void
{
if (evt.info.code == "NetConnection.Connect.Success")
{
playNs = new NetStream (playNc);
var v: Video = new Video ();
v.width = 320;
v.height = 240;
v.attachNetStream (playNs);
playNs.play (UserName, "live");
this.oneVideo.addChild (v);
}
}

Connected to their release of the video stream, the video stream displayed on the interface.

Text chat using the shared object chat room to do to achieve is very simple, text chat on the implementation details of the shared object can view the "Using the remote shared object (SharedObject) from time to time to achieve more than online chat (Flex | Flash)".

<!--< Br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware) <br /> http://www.CodeHighlighter.com/ <br /> <br /> -->/**
* Send a chat message
* * /
private function sendMessage (evt: MouseEvent): void
{
var tempCollection: ArrayCollection = new ArrayCollection ();
if (so.data.msgCollection! = null)
{
convertArrayCollection (tempCollection, so.data.msgCollection as ArrayCollection);
}
var msg: Message = new Message ();
msg.NickName = myNickName;
msg.Context = this.txtMessage.text;
tempCollection.addItem (msg);

/ / Update a remote shared object property values
so.setProperty ("msgCollection", tempCollection);

this.txtMessage.text = "";
}

private function onSyncHandler (evt: SyncEvent): void
{
if (so.data.msgCollection! = null)
{
/ / Get the first time logging in asynchronous message is not displayed when the message before logging
if (isFirstLogin)
{
so.setProperty ("msgCollection", null);
isFirstLogin = false;
}
else
{
var tempCollection: ArrayCollection = new ArrayCollection ();
convertArrayCollection (tempCollection, so.data.msgCollection as ArrayCollection);

this.displayMessage.text = "";
for (var index: int = 0; index <tempCollection.length; index + +)
{
var message: Object = tempCollection.getItemAt (index);
var displayMessage: String = message.NickName + "says:" + message.Context;
this.displayMessage.text + = displayMessage + "\ n";
}
}
}
this.displayMessage.verticalScrollPosition = this.displayMessage.maxVerticalScrollPosition;
}

When the user logs in front of the user information has been written into the shared object, the user online list of shared objects only need to read out the data displayed on the interface to OK, here using the tree control to render the data.

<!--< Br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware) <br /> http://www.CodeHighlighter.com/ <br /> <br /> -> private function init ( ): void
{
nc = new NetConnection ();
nc.connect ("rtmp: / / localhost / ChatRoom");
nc.addEventListener (NetStatusEvent.NET_STATUS, onNetStatusHandler);
nc.client = this;

so = SharedObject.getRemote ("UserSO");
so.addEventListener (SyncEvent.SYNC, onSyncHandler);
so.connect (nc);
so.client = this;
}

private function onNetStatusHandler (event: NetStatusEvent): void
{
if (event.info.code == "NetConnection.Connect.Success")
{
if (so.data.UserList! = null)
{
var uarray: Array = so.data.UserList as Array;
this.userTree.dataProvider = uarray;
}
}
}

private function onSyncHandler (event: SyncEvent): void
{
if (so.data.UserList! = null)
{
var uarray: Array = so.data.UserList as Array;
this.userTree.dataProvider = uarray;
}
}

FMS Case Development - Video chat room (c) [switch]

相关文章
  • FMS Case Development - Video chat room (c) [switch] 2010-12-25

    This paper describes the main content to use SharedObject to implement text chat and online chat user list, and the achievement of voice and video chat. Previous article introduces the realization of user registration and login function, this paper i

  • FMS3 series (VII): FMS case development - video chat room [transfer] 2010-12-25

    FMS3 series of articles have been written to the first seven, and this series of articles focusing initiate the development of FMS is the more common and frequently used function point introduced, the before and after the introduction from the FMS in

  • FMS Case Development - Video chat room (a) [transfer] 2010-12-25

    FMS3 series of articles have been written to the first seven, and this series of articles focusing initiate the development of FMS is the more common and frequently used function point introduced, the before and after the introduction from the FMS in

  • FMS Case Development - Video chat room (b) [transfer] 2010-12-25

    By the previous simple analysis, the following formal entry into the video chat room design and development phase. Based on my previous experience in software development and management, we start from the basic module, first module design and develop

  • Through the FMS real-time video chat to switch 2010-04-27

    Video chat from time to time through the FMS implementation is actually very simple operation that is always current. If it is a one-way video chat, then both ends of the side of the side of the end for the release side of the subscription side, if a

  • FMS3 series (V): from time to time video chat to achieve through the FMS (Flash | Flex) [switch] 2010-12-25

    nc.connect ("rtmp: / / localhost / LiveStreams"); nc.addEventListener (NetStatusEvent.NET_STATUS, onNetStatusHandler); } private function onNetStatusHandler (evt: NetStatusEvent): void { trace (evt.info.code); if (evt.info.code == "NetConne

  • FMS3 Series (5): from time to time video chat to achieve through the FMS (Flash | Flex) 2010-09-21

    This series of articles, respectively, the first introduced, FMS server connection established player and online video recording and playback implementation. Have seen the articles in front of friends have a certain understanding of the FMS, and fami

  • FMS3 series (V): from time to time video chat to achieve through the FMS (Flash | Flex) 2010-09-21

    Previous articles in this series were introduced in connection FMS server, create player and online video recording and playback functions such as implementation. Read the previous articles that friends have a certain understanding of FMS, and famili

  • Video chat software development technology 2011-02-22

    Internet video is like a kaleidoscope, it is all obsessed with visual, audible to find a crowd of dripping fun way, it brings users a true audio-visual stimulation and facial images. The industry's rapid rise to the network closer to reality, leaving

  • Video chat sites on the technology. Developments. Next Detailed 2010-12-22

    This paper describes the technology related to video chat site, development and future trends. I have long engaged in the outsourcing business development and technology development, and learned a lot from the client's needs related to video chat sit

  • as3.0 + fms implement a video communication system 2010-08-21

    These are all long time ago when playing flash write, for fear away, do not know the future also with no use, after all, write the very values taken Oh! So what made up the backup, while a little to the need to help! Learn as3 will then learn fms: ma

  • GMail add 'voice and video chat' support 2011-02-18

    GMail to increase support for video chat (you may need proxy access only) Need to install additional plug-ins to support plug-ins will be installed in C: \ Documents and Settings \ UserName \ Local Settings \ Application Data \ Google \ Google Talk P

  • FMS3 series (a): The first FMS program, connect to the FMS server (Flash / Flex implementation of two) [switch] 2010-12-25

    FMS is a very cattle X thing, in the end a number of cattle X I do not want to say, interested friends can baidu a look, if you really do not want to get involved, then you point the link below, and I search for a point brief summary of the informati

  • YbmNMS (OpenNMS English Version) Development Video 2010-07-20

    Development environment with a linux test machine, cvs server (for code update), developed using the personal computer, using eclipse as IDE. Video aims to initiate the secondary development needs to have opennms friends show basic development, testi

  • Flex3 + Red5 2 voice and video chat program 2010-12-06

    Flex3 part <? Xml version = "1.0" encoding = "utf-8"?> <MX: WindowedApplication xmlns: MX = " http://www.adobe.com/2006/mxml "layout =" Absolute "> <mx:Script> <! [CDATA [ import mx.events.Close

  • [Cocos2d development of the three] CCScene switch all effects, and set the screen the screen anyway! 2011-09-28

    CCScene cocos2d of shoes for use must be very familiar with, then use [[CCDirectorsharedDirector] replaceScene: <# (CCScene *) scene #>]; on the scene to scene (CCLayout) for switching, cocos2d provides special effects for the transition, then caref

  • Video Conference Source (client and server side, including the complete development documentation) 2010-12-13

    A, SDK package overview AnyChat interactive audio and video development platform (SDK) is a cross-platform instant messaging solution, based on the advanced video coding standard H.264, AAC audio coding standard and P2P technology, the integration of

  • Recommend the best audio and video development platform 2011-02-21

    AnyChat interactive audio and video development platform (SDK) is a cross-platform instant messaging solution, based on the advanced H.264 video coding standard, AAC audio coding standard and P2P technology, the integration of Bai Rui technology in a

  • FLEX development direction, very useful 2010-11-25

    For the FLEX FLASH itself, especially in terms of standard form FLEX to offer a lot of to use for beginners and developing it so easy. The most typical application is to be a ** applications, forms, tree, kind of form submission. But if you say you w

  • Flex FMS application (on) 2010-12-09

    Heard so much about "fms" name for a long time, but know it has been flawless. Today, a recording device project lit the fuse of learning to learn it Some basic concepts of FMS Macromedia released late in 2002, surprising the previous version of