FlashCom+&Asp/Asp.Net 实现WEB视频聊天

来源:互联网 发布:国家电网数据运维考试 编辑:程序博客网 时间:2024/04/29 02:22
要安装 flashcom 测试版本可以在media上下载。

代码如下:

[JaSoft.Aspx]

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

private void Page_Load(object sender, System.EventArgs e) 

Response.Write("conn=1&Sendid="+Session["ziyan"]+"&Recvid="+Session["sammi"]); 

</script> 


[View.Aspx]

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

private void Page_Load(object sender, System.EventArgs e) 

Session["ziyan"]=Request.QueryString["RecvId"]; 
Session["sammi"]=Request.QueryString["Sendid"]; 

</script> 
<html> 
<head> 
<meta http-equiv="Content-Language" content="zh-cn"> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
<title>无标题文档</title> 
</head> 

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div align="center">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-44553540000" 
codebase= http://download.macromedia.com/pub/shockwave
/cabs/flash/swflash.cab#version=6,0,29,0 width="500" height="500">
<param name="menu" value="false">
<param name="movie" value="JaSoft.swf">
<param name="quality" value="high">
<embed src="JaSoft.swf" quality="high" pluginspage=
http://www.macromedia.com/go/getflashplayer 
type="application/x-shockwave-flash" width="500" height="500"> </embed></object>
</div>
</body> 
</html> 

[JaSoft.Swf]

stop(); 
myCam = Camera.get();
myVideoObject.attachVideo(myCam);
myCam.onStatus = function(infoMsg) {

if(infoMsg.code == "Camera.Muted"){
_root.a.text="User denies access to the camera";
}
else
System.showSettings(0);
}


client_nc = new NetConnection(); 

client_nc.onStatus = function(info) { 
trace("Level: "+info.level+newline+"Code: "+info.code); 
_root.abc.text = "Level: "+info.level+newline+"Code: "+info.code;
}; 

client_nc.connect("rtmp://192.168.25.18/record_video"); 

rec_so = SharedObject.getRemote("myvideo", client_nc.uri, true); 


rec_so.connect(client_nc); 
var Recvid; 
var Sendid; 
GetId(); 
function Recv() { 

in_ns = new NetStream(client_nc); 

in_ns.play(Recvid); 
_root.b.attachVideo(in_ns); 


function Send() { 
this.cam = Camera.get(); 
this.mic = Microphone.get(); 
out_ns = new NetStream(client_nc); 

out_ns.attachVideo(this.cam); 
_root.a.attachVideo(this.cam); 

out_ns.attachAudio(this.mic); 
out_ns.publish(Sendid, "live"); 


function GetId(){ 
myload = new LoadVars(); 

myload.action = "post"; 

myload.onLoad = function(success) { 

if (success) { 

if (this.conn == "1") { 
_root.Recvid = this.Recvid; 
_root.Sendid = this.Sendid; 
Send(); 
Recv(); 
_root.abc.text =’ok...’; 

} else { 
//如果和服务器连接不成功则返回失败消息,需要检查路径是否正确 
_root.abc.text = ’连接不成功....’;

}; 
myload.sendAndLoad("http://192.168.25.18/Asp.Net/JaSoft.aspx", myload, "post");