Files
SIPAIIS_WMS_JSSW/WebRoot/jsp/work/cameraVideoJsp.jsp
2026-01-16 14:13:44 +08:00

106 lines
4.5 KiB
Plaintext

<%@ page language="java" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ page import="com.sipai.entity.base.ServerObject" %>
<%@ taglib uri="http://www.springsecurity.org/jsp" prefix="security" %>
<!DOCTYPE html>
<head>
<title><%= ServerObject.atttable.get("TOPTITLE")%>
</title>
<!-- 引用页头及CSS页-->
<jsp:include page="/jsp/inc.jsp"></jsp:include>
<style type="text/css">
</style>
<script type="text/javascript">
$(function () {
var width = $(window).width();
var height = $(window).height();
$('#videos').css('width', width);
$('#videos').css('height', height);
viewThisCamera('${id}', '${online}');
});
$(window).resize(function () {
var width = $(window).width();
var height = $(window).height();
$('#videos').css('width', width);
$('#videos').css('height', height);
});
function viewThisCamera(id, online) {
// console.log(id + '---' + online);
if (!online) {
swal('该摄像头无法连接。');
return;
}
var websocket = null;
var restartDialog;
//判断当前浏览器是否支持WebSocket
if ('WebSocket' in window) {
var time = '${time}';
if (time == null || time == '') {
time = "now";
}
$.post(ext.contextPath + '/work/camera/getCameraById.do', {
id: id
}, function (data) {
var camera = JSON.parse(data);
$.ajax({
type: 'GET',
url: ext.contextPath + "/work/camera/isNet.do?nowUrl=" + window.location.host,
async: false,
globle: false,
dataType: 'json',
error: function () {
return false;
},
success: function (data) {
let hostUrl = window.location.href;
if (hostUrl.substring(0, 5) == 'https') {
data.url = data.url.replace('ws', 'wss');
}
websocket = new WebSocket("" + data.url + "/videoWebSocket/" + camera.type + "/" + camera.url + "/" + camera.username + "/" + camera.password + "/" + camera.channel + "/" + time + "/${uuid}" + "/high");
<%--if (data.type == '1') {--%>
<%-- websocket = new WebSocket("" + data.url + "/videoWebSocket/" + camera.type + "/" + camera.url + "/" + camera.username + "/" + camera.password + "/" + camera.channel + "/" + time + "/${uuid}" + "/high");--%>
<%--} else if (data.type == '2') {--%>
<%-- websocket = new WebSocket("" + data.url + "/videoWebSocket/" + camera.type + "/" + camera.netUrl + "/" + camera.username + "/" + camera.password + "/" + camera.channel + "/" + time + "/${uuid}" + "/high");--%>
<%--}--%>
}
});
websocket.onerror = function () {
};
//连接成功建立的回调方法
websocket.onopen = function () {
console.info('消息滚动websocker开启');
}
//接收到消息的回调方法
websocket.onmessage = function (event) {
// var result = JSON.parse(event.data);
$("#show_video_1").attr("src", event.data);
}
})
<%--websocket = new WebSocket(ext.basePath.replace("http", "ws") + "/videoWebSocket/" + id + "/" + time + "/${uuid}");--%>
} else {
alert('当前浏览器 Not support websocket')
}
}
</script>
</head>
<body style="background-color: rgb(23, 39, 55);">
<div id="videos" style="float: left;background-color: rgb(23, 39, 55);">
<div style="width: 100%;height: 100%;float: left;background-color: rgb(23, 39, 55);" id="video_1">
<img id="show_video_1" style="width: 100%;height: 100%;" src="">
</div>
</div>
</body>
</html>