要安裝 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");
}