|
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>video</title>
</head>
<body>
<input type="button" value="登录" onclick="testLogin()" />
<input type="button" value="打开视频" onclick="testOpenVideo()" />
<div id="id_video" style="width:500px; height:400px;background: black;"></div>
</body>
</html>
<script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="http://61.191.27.18:8081/js/jsw.js"></script>
<!-- <script type="text/javascript" src="js/anjular.min.js"></script> -->
<script type="text/javascript">
var session = null;
//这就是为了获取登录过的session的接口
var rc;
window.onload = function () {
rc = jSW.swInit({
url: "http://47.92.130.204:9701", // bv_nginx.exe服务器地址
calltype: jSW.CallProtoType.AUTO, // AUTO: IE优先使用OCX, 如果希望IE仍然使用HTTP通信, 请使用jSW.CallProtoType.HTTP
/* oninit: onInitHasResult */
});
testLogin();
testOpenVideo();
}
window.onbeforeunload = function () {
jSW.swDeInit();
}
function onInitHasResult(rcInitResult){
if(rc == jSW.RcCode.RC_CODE_S_OK){
/* testLogin();
testOpenVideo(); */
}
}
function testLogin(){
if (session) { delete session; }
session = new jSW.SWSession({
server: '47.92.130.204', // 如果是jSW.CallProtoType.OCX方式,这里需要填写具体的IP
port: 9701,
onopen: function (sess) {
sess.swLogin({
user: 'TEST1',
password: '123456'
});
}
});
/* session.swAddCallBack('login', sessionCallback); */
}
function sessionCallback(sender, event, json) {
var info = '';
if (json.code == jSW.RcCode.RC_CODE_S_OK) {
alert("成功");
}
}
function testOpenVideo() {
var szPuid = 'PU_23295583';
var chanel = session.swGetPuChanel('PU_23295583', 0);
var strVideoDivId = document.getElementById('id_video');
if (chanel) {
var result = chanel.swOpenEx({
div: strVideoDivId,
prototype: 'auto', //rtmp > hls
callback: function (options, response) {
alert(response.emms.code + "视频打开成功,可以获取URl了");
}
});
if (result != jSW.RcCode.RC_CODE_S_OK) {
alert('打开视频失败: ' + result);
}
} else {
alert('没有该设备通道');
}
}
function testGetUrlVideo() {
var szPuid = $("#puid").val();
var chanel = session.swGetPuChanel(szPuid, 0);
var url = chanel.swGetUrl();
document.getElementById('id_url_info').innerHTML = JSON.stringify(url, null, 4);
}
function testCloseVideo() {
var szPuid = $("#puid").val();
var chanel = session.swGetPuChanel(szPuid, 0);
chanel.swClose();
}
</script> |
|