195 lines
4.8 KiB
HTML
195 lines
4.8 KiB
HTML
<!doctype html>
|
||
<html>
|
||
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<!-- <script type="text/javascript" src="./uni.webview.js"></script> -->
|
||
<!-- <script src="./h5player.min.js"></script> -->
|
||
<script type="text/javascript" src="./h5player.min.js"></script>
|
||
<script type="text/javascript" src="./uni.webview.1.5.5.js"></script>
|
||
<style type="text/css">
|
||
.myplayer {
|
||
/* width: 100vw; */
|
||
/* height: 28vh; */
|
||
/* height: 100vh; */
|
||
/* min-height: 225px; */
|
||
/* border-radius: 2vh; */
|
||
overflow: hidden;
|
||
/* background: #000; */
|
||
}
|
||
|
||
body {
|
||
margin: 0;
|
||
}
|
||
</style>
|
||
</head>
|
||
|
||
<body>
|
||
<div id="play_window" class="myplayer"></div>
|
||
<script>
|
||
let fullScreen = false;
|
||
console.log('Initializing decoder...');
|
||
var myPlugin = new JSPlugin({
|
||
szId: 'play_window',
|
||
szBasePath: './',
|
||
iOSDecodePath: './playctrl1/'
|
||
})
|
||
// 事件回调绑定
|
||
myPlugin.JS_SetWindowControlCallback({
|
||
windowEventSelect: function(iWndIndex) {
|
||
//插件选中窗口回调
|
||
console.log("windowSelect callback: ", iWndIndex);
|
||
},
|
||
pluginErrorHandler: function(iWndIndex, iErrorCode, oError) {
|
||
//插件错误回调
|
||
console.log("pluginError callback: ", iWndIndex, iErrorCode, oError);
|
||
},
|
||
performanceLack: function(iWndIndex) {
|
||
//性能不足回调
|
||
console.log("performanceLack callback: ", iWndIndex);
|
||
},
|
||
StreamEnd: function(iWndIndex) {
|
||
//性能不足回调
|
||
console.log("recv StreamEnd: ", iWndIndex);
|
||
},
|
||
talkPluginErrorHandler: (iErrorCode, oErrorInfo) => { //对讲错误回调
|
||
console.log('recv talkPluginErrorHandler: ' + iErrorCode);
|
||
},
|
||
});
|
||
|
||
window.handleMessage = function(msg) {
|
||
console.log("接收到消息", msg);
|
||
// alert("接收到消息"+msg);
|
||
// document.getElementById('box').innerText = msg;
|
||
const data = JSON.parse(msg)
|
||
if (data.type === "start") {
|
||
talkStart(data.url)
|
||
} else {
|
||
talkStop()
|
||
}
|
||
}
|
||
|
||
|
||
// play()
|
||
// myPlugin.JS_FullScreenDisplay(true)
|
||
// myPlugin.JS_FullScreenSingle(0)
|
||
|
||
function play() {
|
||
// 视频流流
|
||
var playURL = GetQueryString("cameraUrl")
|
||
console.log('视频流地址:', playURL)
|
||
// 窗口下标
|
||
var curIndex = 0;
|
||
// 获取监控点唯一标识,方便作为抓图存储的key
|
||
// var cameraIndexCode = GetQueryString("cameraIndexCode")
|
||
// 视频预览
|
||
myPlugin.JS_Play(playURL, {
|
||
playURL,
|
||
mode: 0 // 0 普通模式 / 1 高级模式
|
||
}, curIndex).then(() => {
|
||
console.info('JS_Play success ');
|
||
// 设置取流连接超时时间
|
||
let nTime = 300000
|
||
myPlugin.JS_SetConnectTimeOut(curIndex, nTime).then(
|
||
() => {
|
||
console.info('JS_SetConnectTimeOut success');
|
||
// do you want...
|
||
|
||
myPlugin.JS_OpenSound(curIndex).then(
|
||
() => {
|
||
console.info('JS_OpenSound success');
|
||
// do you want...
|
||
},
|
||
(err) => {
|
||
console.info('JS_OpenSound failed');
|
||
// do you want...
|
||
}
|
||
);
|
||
},
|
||
(err) => {
|
||
console.info('JS_SetConnectTimeOut failed', err);
|
||
// do you want...
|
||
}
|
||
);
|
||
}, (err) => {
|
||
console.info('JS_Play failed:', err);
|
||
// do you want...
|
||
});
|
||
myPlugin.JS_FullScreenDisplay(true)
|
||
// myPlugin.JS_FullScreenSingle(curIndex)
|
||
//开启声音
|
||
}
|
||
|
||
// 截图
|
||
function onScreenshot() {
|
||
console.log('点击截屏');
|
||
// 窗口下标
|
||
var curIndex = 0;
|
||
// 获取监控点唯一标识,方便作为抓图存储的key
|
||
// var cameraIndexCode = GetQueryString("cameraIndexCode")
|
||
// 文件名称
|
||
var fileName = 'img';
|
||
// 文件类型
|
||
var fileType = 'JPEG';
|
||
//下载到本地
|
||
myPlugin.JS_CapturePicture(curIndex, fileName, fileType).then(
|
||
(res) => {
|
||
console.info('JS_CapturePicture success');
|
||
// do you want...
|
||
},
|
||
(err) => {
|
||
console.info('JS_CapturePicture failed', err);
|
||
// do you want...
|
||
}
|
||
);
|
||
}
|
||
|
||
//取url中的参数值
|
||
function GetQueryString(name) {
|
||
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
|
||
var r = window.location.search.substr(1).match(reg);
|
||
if (r != null) return unescape(r[2]);
|
||
return null;
|
||
}
|
||
|
||
function talkStart(url) {
|
||
myPlugin.JS_SetConnectTimeOut(0, 1000)
|
||
console.log(url);
|
||
console.log(myPlugin);
|
||
myPlugin.JS_StartTalk(url).then(
|
||
() => {
|
||
console.log('talkStart success')
|
||
// alert('对讲连接成功')
|
||
webUni.postMessage({
|
||
data: {
|
||
msg: 'success'
|
||
}
|
||
});
|
||
},
|
||
e => {
|
||
console.error(e)
|
||
// alert('对讲连接失败' + e)
|
||
webUni.postMessage({
|
||
data: {
|
||
msg: 'error',
|
||
err: e
|
||
}
|
||
});
|
||
}
|
||
)
|
||
}
|
||
|
||
function talkStop() {
|
||
myPlugin.JS_StopTalk().then(
|
||
() => {
|
||
console.log('talkStop success')
|
||
},
|
||
e => {
|
||
console.error(e)
|
||
}
|
||
)
|
||
}
|
||
</script>
|
||
</body>
|
||
|
||
</html> |