|
<div id='id_video' style="border: 1px solid black;width:100%;height:100%;"></div>
<script type="text/javascript">
var hndSession = null;
window.onload = function () {
jSW.swInit({
url: "http://117.186.28.121:8081", // bv_nginx.exe服务器地址
calltype: jSW.CallProtoType.HTTP, // AUTO: IE优先使用OCX, 如果希望IE仍然使用HTTP通信, 请使用jSW.CallProtoType.HTTP
});
}
window.onbeforeunload = function () {
var szPuid ="<%=PUID%>";
var chanel = hndSession.swGetPuChanel(szPuid, 0);
chanel.swClose();
return '';
}
$(function(){
setTimeout(function(){
hndLogin();
},1000);
;
});
//登录
function hndLogin(){
if (hndSession) { delete hndSession; }
hndSession = new jSW.SWSession({
server: '117.186.28.121', // 如果是jSW.CallProtoType.OCX方式,这里需要填写具体的IP
port: 9701,
onopen: function (sess) {
sess.swLogin({
user: 'admin',
password: '123456'
});
}
});
// 注册事件的回调函数
hndSession.swAddCallBack('login', sessionCallback);
}
function sessionCallback(sender, event, json) {
if (json.code == jSW.RcCode.RC_CODE_S_OK) {
setTimeout(function(){
playVideo();
},2000);
}
}
/*
* msgType: 消息类型
*
*/
function mpOnMessage(msgType, data){
if(data){
windowIndex=data.playid;
}
}
function playVideo(){
var szPuid ="<%=PUID%>";
var channelindex = 0;
var chanel = hndSession.swGetPuChanel(szPuid, channelindex);
var mediaDir = jSW.MEDIADIR.VIDEORECV;
mediaDir = mediaDir | jSW.MEDIADIR.AUDIORECV
var result = chanel.swOpenEx({
bwindowless:false,
bstretch:true,
callback: function (options, response) {
if (response.emms.code == jSW.RcCode.RC_CODE_S_OK) {
console.log("ok");
}
},
div: 'id_video',
media: mediaDir
});
};
</script>
|
|