Online Video Chat Using Flash COM + Asp.net Technology

Source: Internet
Author: User
Online Video Chat Using Flash COM + Asp.net Technology

Online Video chat and communication are currently popular

However, using web videos is not that simple.

In the past, there were two ways to achieve one was to use the customer service Active Control and the other was to use the Java app, but both were not ideal.
One is that network signal collection cannot adapt to bandwidth, and the other is technical difficulties. Currently, the popular bchat is the first method, but I still cannot separate the control, I will not talk about the second method of selling free or commercial ready-made controls on the Internet, because Windows XP and above do not support Java.

However, the new Flash Communication Server MX Technology launched by Macromedia is easy to implement. For more information, visit the internet.
There are several existing examples after downloading the test version. Here we will talk about how to use aspx and flash to communicate with each other.


Send the finished image here.
This is a QQ-like online communication system written by Asp.net + SQL.

Functions are good. QQ functions are available here.

I was most proud to realize the video function.

The video function of Flash is in B-S-B mode, that is, there will be a zero-time video file in the service segment.
The specific code is packaged for download.

Key Points of writing
Sp. aspx

<% @ Language = "C #" %>
<SCRIPT runat = "server">

Private void page_load (Object sender, system. eventargs E)
{
Response. Write ("conn = 1 & sendid =" + session ["NMD"] + "& recvid =" + session ["recvid"]);
}
</SCRIPT>

Cam. aspx

<% @ Page Language = "C #" %>
<SCRIPT runat = "server">

Private void page_load (Object sender, system. eventargs E)
{
Session ["recvid"] = request. querystring ["recvid"];
}
</SCRIPT>
<HTML>
<Head>
<Meta http-equiv = "content-language" content = "ZH-CN">
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Title> untitled document </title>
</Head>

<Body leftmargin = "0" topmargin = "0" marginwidth = "0" marginheight = "0">
<Object classid = "CLSID: D27CDB6E-AE6D-11cf-96B8-444553540000" codebase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width = "220" Height = "200">
<Param name = "movie" value = "sp.swf">
<Param name = "quality" value = "high">
<Embed src = "sp.swf" Quality = "high" pluginspage = "http://www.macromedia.com/go/getflashplayer" type = "application/X-Shockwave-flash" width = "220" Height = "200"> </embed> </Object>

</Body>
</Html>

Corner of sp.swf
Stop ();
Client_nc = new netconnection ();
// Netconnection. onstatus (para) is used to monitor the information returned by the server.
// When the server returns information, this processor is triggered
// A parameter is an object that contains the returned information. It contains two fixed variables: Level and code. The parameter name can be named casually.
Client_nc.onstatus = function (Info ){
// Use the trace function to visualize the information returned by the server
Trace ("level:" + info. Level + newline + "Code:" + info. Code );
};
// Connect to the server and establish an rtmp connection
// The following is the relative address, because my web server and Flash Communication Server are on one machine.
// If your web server and Flash Communication Server are not on the same machine, the IP addresses of the two machines must be in the same domain.
// You can establish a connection and write it as client_nc.connect ("rtmp:/192.168.0.1/record_video ");
// Record_video is the name of the folder, which must exist in advance.
// Assume that you install the communication server by default, the record_video folder should be placed in
// C:/program files/Macromedia/Flash Communication Server MX/flashcom/Applications
Client_nc.connect ("rtmp: // 192.168.0.2/record_video ");
// Use the export dobject. getremote method to create a remote export dobject
// "Myvideo" is the sharedobject file name, and the file on the server hard disk is myvideo. FSO
// Client_nc.uri is a required parameter pointing to the current rtmp connection.
// The third parameter is an optional parameter. True indicates that myvideo. FSO is written to the hard disk. False, null, or omitted means that no data is written and only temporarily exists.
Rec_so = export dobject. getremote ("myvideo", client_nc.uri, true );
// Synchronized dobject. onsync (para) is used to dynamically monitor sharedobject changes
// This processor is triggered whenever mongodobject changes
// The parameter is an array that records the changed content in mongodobject. Data.
// Each member of the array is an object, and the object has two members, code and name.
// Name indicates the changed content in mongodobject. Data.
// Code indicates the changes in the content, which is the information returned by the system.
// Connect the export dobject function to the server
Rec_so.connect (client_nc );
VaR recvid;
VaR sendid;
GETID ();
Function Recv (){

// Create a new netstream Stream object to play the message
In_ns = new netstream (client_nc );
// Use netstream. play to play FLV files on the server
In_ns.play (recvid );
Mybox. attachvideo (in_ns );
}

Function send (){
This. Cam = camera. Get ();
This. MIC = microphone. Get ();
// Create a netstream object on the client_nc connection
Out_ns = new netstream (client_nc );
// Use netstream. attachvideo to obtain the camera image
Out_ns.attachvideo (this. Cam );
// Obtain the microphone sound through netstream. attachaudio
Out_ns.attachaudio (this. Mic );
Out_ns.publish (sendid, "live ");
}

Function GETID (){
// Construct a new loadvars object
Myload = new loadvars ();
// Set the action of myload for server Verification
Myload. Action = "Post ";
// Verify the function connected to the server
Myload. onload = function (SUCCESS ){
// If the connection is successful with the server...
If (SUCCESS ){
// If the verification action is successful...
If (this. Conn = "1 "){
// Assign the output variable in the returned object to the dynamic text box in which VaR is output in the scenario.
_ Root. recvid = This. recvid;
_ Root. sendid = This. sendid;
Send ();
Recv ();
}
} Else {
// If the connection to the server is unsuccessful, a failure message is returned. Check whether the path is correct.

}
};
Myload. sendandload ("http: // localhost/webqq/sp. aspx", myload, "Post ");
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.