Browse Source

调整视频预览

lite
453530270@qq.com 3 years ago
parent
commit
7040bb68cb
  1. 8
      src/router/index.js
  2. 239
      src/views/test.vue
  3. 18
      src/views/ty/index.vue

8
src/router/index.js

@ -24,7 +24,13 @@ const routes = [
path: '/ty', path: '/ty',
name: 'ty', name: 'ty',
component: ()=>import("../views/ty/index.vue"), component: ()=>import("../views/ty/index.vue"),
} },
{
path: '/test',
name: 'test',
component: ()=>import("../views/test.vue"),
},
] ]
const router = new VueRouter({ const router = new VueRouter({

239
src/views/test.vue

@ -0,0 +1,239 @@
<template>
<div id="hkzone">
<video style="width: 68%;height: 70%;position: absolute;top: 0.3rem;left: 0.3rem;" id="camera0"
autoplay></video>
</div>
</template>
<script>
// api
import * as homeApi from '@/api/home'
import $ from "jquery";
export default {
data() {
return {
//
videoData: [],
}
},
created() {
this.initPlugin();
},
mounted() {
this.getVideo()
},
methods: {
//
getVideo() {
let that = this
homeApi.allGetVideo().then(res => {
// get allTimeData
const tmpdata = res.data.videoData
let baseviode = this.decode(tmpdata)
let baseviodejson = this.sec_decode(baseviode)
var jsonParseJson = JSON.parse(baseviodejson);
this.videoData = jsonParseJson
});
},
//
decode(str) {
if (str === undefined || str === "" || str === null) {
return str;
}
// Going backwards: from bytestream, to percent-encoding, to original string.
return decodeURIComponent(atob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).slice(0, -2).join(''));
},
//
sec_decode(str) {
if (str === undefined || str === "" || str === null) {
return str;
}
// Going backwards: from bytestream, to percent-encoding, to original string.
return decodeURIComponent(atob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
},
//
initPlugin() {
let _that = this;
const oWebControl0 = new window.WebControl({
szPluginContainer: 'camera0', // id
iServicePortStart: 15900, // 使
iServicePortEnd: 15900,
szClassId: '23BF3B0A-2C56-4D97-9C03-0CB103AA8F11', // IE10使ActiveXclsid
cbConnectSuccess() {
// console.log('WebControl1');
$('#camera0').html('创建WebControl实例成功1');
oWebControl0.JS_StartService('window', {
// WebControl
dllPath: './VideoPluginConnect.dll', // "./VideoPluginConnect.dll"
}).then(
() => {
// //
// oWebControl0.JS_SetWindowControlCallback({
// //
// cbIntegrationCallBack: _that.cbIntegrationCallBack,
// });
oWebControl0.JS_CreateWnd('camera0').then(() => {
//JS_CreateWnd
_that.init(); //
});
},
() => {
//
console.log('启动插件服务失败');
}
)
.catch((err) => {
console.log(err);
});
},
cbConnectError() {
// WebControl
console.log('xxx');
oWebControl0 = null;
$('#camera0').html('插件未启动,正在尝试启动,请稍候...');
window.WebControl.JS_WakeUp('VideoWebPlugin://'); // errorwakeup
this.initCount++;
if (this.initCount < 3) {
setTimeout(function () {
this.initPlugin();
}, 3000);
} else {
$('#camera0').html('插件启动失败,请检查插件是否安装!');
}
},
cbConnectClose(bNormalClose) {
// bNormalClose = false
// JS_DisconnectbNormalClose = true
console.log('cbConnectClose');
oWebControl0 = null;
},
});
this.oWebControl0 = oWebControl0;
},
//
init() {
let _that = this;
_that.getPubKey(function () {
//
// console.log(typeof(_that.videoData[0].host));
var port = 8442;
var appkey = _that.videoData[0].appkey; //appkey
var secret = _that.setEncrypt(_that.videoData[0].secret); //secret
var ip = _that.videoData[0].host; //IP
var playMode = 0; //0-1-
var port = port; //HTTPS443
// var snapDir = ""; //
// var videoDir = "D:\\VideoDir"; //
var layout = "1x1"; //playMode
var enableHTTPS = 1; //HTTPS1
var encryptedFields = "secret"; //secret
var showToolbar = 0; //0-0-
var showSmart = 1; //线0-0-
var buttonIDs = "0,16,256,257,258,259,260,512,513,514,515,516,517,768,769"; //
//
_that.oWebControl0.JS_RequestInterface({
funcName: "init",
argument: JSON.stringify({
appkey: appkey, //APIappkey
secret: secret, //APIsecret
ip: ip, //APIIP
playMode: playMode, //
port: port, //
// snapDir: snapDir, //
// videoDir: videoDir, //
layout: layout, //
enableHTTPS: enableHTTPS, //HTTPS
encryptedFields: encryptedFields, //
showToolbar: showToolbar, //
showSmart: showSmart, //
buttonIDs: buttonIDs, //
}),
})
.then((oData) => {
let width = document.querySelector("#camera0").offsetWidth;
let height = document.querySelector("#camera0").offsetHeight;
_that.oWebControl0.JS_Resize(width, height); // resize
// console.log(oData);
// console.log(width, height);
_that.getVideoFun(_that.videoData[0].cameraIndexCode)
});
});
},
//
getPubKey(callback) {
this.oWebControl0.JS_RequestInterface({
funcName: "getRSAPubKey",
argument: JSON.stringify({
keyLength: 1024,
}),
})
.then((oData) => {
if (oData.responseMsg.data) {
this.pubKey0 = oData.responseMsg.data;
callback();
}
});
},
//RSA
setEncrypt(value) {
var encrypt = new window.JSEncrypt();
encrypt.setPublicKey(this.pubKey0);
return encrypt.encrypt(value);
},
//
getVideoFun(Code) {
//
var cameraIndexCode = Code; //
var streamMode = 1; //0-1-
var transMode = 1; //0-UDP1-TCP
var gpuMode = 1; //GPU0-1-
var wndId = -1; //2x2
cameraIndexCode = cameraIndexCode.replace(/(^\s*)/g, "");
cameraIndexCode = cameraIndexCode.replace(/(\s*$)/g, "");
console.log(cameraIndexCode);
this.oWebControl0.JS_RequestInterface({
funcName: "startPreview",
argument: JSON.stringify({
cameraIndexCode: cameraIndexCode, //
streamMode: streamMode, //
transMode: transMode, //
gpuMode: gpuMode, //GPU
wndId: wndId, //
}),
})
.then((res) => {
//
// console.log('')
//console.log(res);
},
err => {
//console.log('')
//console.log(preUrl);
// console.info('JS_Play failed:', err)
console.info(err)
});
},
destroyVideoDiv() {
this.oWebControl2.JS_DestroyWnd()
.then((data) => {
console.log("销毁窗口成功");
})
.catch((err) => {
console.log("销毁窗口失败");
});
},
//
},
}
</script>

18
src/views/ty/index.vue

@ -42,11 +42,11 @@
<div class="center"> <div class="center">
<!-- v-for=" item in videoData" :key="item.key" --> <!-- v-for=" item in videoData" :key="item.key" -->
<div class="item" v-for=" item in videoData" :key="item.key" style="position: relative;"> <!-- <div class="item" v-for=" item in videoData" :key="item.key" style="position: relative;">
<video style="width: 68%;height: 70%;position: absolute;left: 0.3rem;top: 0.3rem;" :id="item.key" <video style="width: 68%;height: 70%;position: absolute;left: 0.3rem;top: 0.3rem;" :id="item.key"
autoplay></video> autoplay></video>
</div> </div> -->
<!-- <div class="item" style="position: relative;"> <div class="item" style="position: relative;">
<video style="width: 68%;height: 70%;position: absolute;top: 0.3rem;left: 0.3rem;" id="camera0" <video style="width: 68%;height: 70%;position: absolute;top: 0.3rem;left: 0.3rem;" id="camera0"
autoplay></video> autoplay></video>
</div> </div>
@ -55,7 +55,7 @@
</div> </div>
<div class="item"> <div class="item">
<video style="width: 68%;margin-top: 0.3rem;height: 70%;margin-left: 0.3rem;" id="camera2" autoplay></video> <video style="width: 68%;margin-top: 0.3rem;height: 70%;margin-left: 0.3rem;" id="camera2" autoplay></video>
</div> --> </div>
</div> </div>
<div class="right"> <div class="right">
@ -178,11 +178,11 @@ export default {
}, },
created() { created() {
// this.$nextTick DOM使DOM // this.$nextTick DOM使DOM
// this.$nextTick(() => { this.$nextTick(() => {
// this.initPlugin(); this.initPlugin();
// this.initPlugin2(); this.initPlugin2();
// this.initPlugin3(); this.initPlugin3();
// }); });
}, },

Loading…
Cancel
Save