Browse Source

海康视频测试

lite
‘daijinzheng@xingtongworld.com’ 2 years ago
parent
commit
4d1a2317f7
  1. 10
      package-lock.json
  2. 4
      package.json
  3. 74
      public/static/jquery-1.12.4.min.js
  4. 1
      public/static/jsencrypt.min.js
  5. 2
      public/static/web-control_1.2.5.min.js
  6. 308
      src/views/ty/index.vue
  7. 166
      src/views/ty/index4.vue
  8. 348
      src/views/ty/index6.vue
  9. 2
      vue.config.js

10
package-lock.json

@ -9422,6 +9422,11 @@
}
}
},
"jquery": {
"version": "3.7.0",
"resolved": "https://registry.npmmirror.com/jquery/-/jquery-3.7.0.tgz",
"integrity": "sha512-umpJ0/k8X0MvD1ds0P9SfowREz2LenHsQaxSohMZ5OMNEU2r0tf8pdeEFTHMFxWVxKNyU9rTtK3CWzUCTKJUeQ=="
},
"js-message": {
"version": "1.0.5",
"resolved": "https://registry.npm.taobao.org/js-message/download/js-message-1.0.5.tgz",
@ -14058,6 +14063,11 @@
"defaults": "^1.0.3"
}
},
"web-control": {
"version": "1.0.2",
"resolved": "https://registry.npmmirror.com/web-control/-/web-control-1.0.2.tgz",
"integrity": "sha512-wYd+WKsS1Fm9Pnsn5QnTIOWomvZq3NFBQ5ZXEwlUPl+55xkVg07omKr3PkkW7HDVvD5H7TWpcB928XxJFSUxNw=="
},
"webpack": {
"version": "4.42.0",
"resolved": "https://registry.npm.taobao.org/webpack/download/webpack-4.42.0.tgz?cache=0&sync_timestamp=1583166824580&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fwebpack%2Fdownload%2Fwebpack-4.42.0.tgz",

4
package.json

@ -16,6 +16,7 @@
"core-js": "^3.6.4",
"echarts": "^5.4.2",
"flv.js": "^1.6.2",
"jquery": "^3.7.0",
"less": "3.9.0",
"less-loader": "4.1.0",
"v-scale-screen": "^1.0.2",
@ -23,7 +24,8 @@
"vue": "^2.6.11",
"vue-awesome": "^4.0.2",
"vue-router": "^3.1.5",
"vuex": "^3.1.2"
"vuex": "^3.1.2",
"web-control": "^1.0.2"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^4.2.0",

74
public/static/jquery-1.12.4.min.js

File diff suppressed because one or more lines are too long

1
public/static/jsencrypt.min.js

File diff suppressed because one or more lines are too long

2
public/static/web-control_1.2.5.min.js

File diff suppressed because one or more lines are too long

308
src/views/ty/index.vue

@ -4,19 +4,10 @@
<div class="main">
<div class="center">
<div id="player" class="item">
<!-- <Video :src="src1" :poster="poster" /> -->
<!-- <video id="myFlvVideo" controls autoplay width="80%" height="200px"></video> -->
<!-- <video class="demo-video" ref="player" muted autoplay></video> -->
<!-- <el-button @click="begin"></el-button> -->
<video id="playWnd" autoplay></video>
<!--v-resize="DomResize" 是用来播放器窗口自适应的如果不需要可以不添加下面会介绍到-->
</div>
<div class="item">
<!-- <Video :src="src2" :poster="poster" /> -->
</div>
<div class="item">
<!-- <Video :src="src3" :poster="poster" /> -->
</div>
<!-- <div class="item"></div> -->
</div>
</div>
@ -25,110 +16,231 @@
</template>
<script>
// import flvjs from "flv.js";
import '@/utils/h5player.min.js'
// import '@/utils/h5player.min.js'
import $ from "jquery";//jquerynpm----npm i jquery -S
import { WebControl } from 'web-control';
export default {
data() {
return {
player: null
initCount: 0,
pubKey: '',
oWebControl2: '',
//便
}
},
mounted() {
created() {
// this.$nextTick DOM使DOM
this.$nextTick(() => {
this.initPlayer()
})
this.initPlugin();
this.getVideoFun('05edddc148b141c5930301af43154942')
});
},
methods: {
/**
* 初始化播放器
*/
initPlayer() {
this.player = new window.JSPlugin({
//
szId: 'player',
// ,H5player.min.jsjs
szBasePath: '../../../src/utils/h5player.min.js'
// // div#play_windowiWidthiHeight
// iWidth: 600,
// iHeight: 400,
// // 4*4
// iMaxSplit: 16,
// iCurrentSplit: 1,
// //
// oStyle: {
// border: '#343434',
// borderSelect: '#FFCC00',
// background: '#000'
// }
})
this.initPlugin()
},
/**
* 事件初始化
*/
//
initPlugin() {
this.player.JS_SetWindowControlCallback({
windowEventSelect(iWindIndex) {
//
console.log('windowSelect callback: ', iWindIndex)
},
pluginErrorHandler(iWindIndex, iErrorCode, oError) {
//
console.error(`window-${iWindIndex}, errorCode: ${iErrorCode}`, oError)
},
windowEventOver(iWindIndex) {
//
console.log('鼠标移过回调', iWindIndex)
let _that = this;
var oWebControl = new WebControl({
szPluginContainer: 'playWnd', // id
iServicePortStart: 15900, // 使
iServicePortEnd: 15909,
szClassId: '23BF3B0A-2C56-4D97-9C03-0CB103AA8F11', // IE10使ActiveXclsid
cbConnectSuccess() {
console.log('创建WebControl实例成功');
oWebControl.JS_StartService('window', {
// WebControl
dllPath: './VideoPluginConnect.dll', // "./VideoPluginConnect.dll"
})
.then(
() => {
// //
oWebControl.JS_SetWindowControlCallback({
//
cbIntegrationCallBack: _that.cbIntegrationCallBack,
});
oWebControl.JS_CreateWnd('playWnd').then(() => {
//JS_CreateWnd
_that.init(); //
console.log('111111111111');
});
},
() => {
//
}
)
.catch((err) => {
console.log(err);
});
},
windowEventOut(iWindIndex) {
//
console.log('鼠标移出回调', iWindIndex)
cbConnectError() {
// WebControl
console.log('xxx');
oWebControl = null;
$('#playWnd').html('插件未启动,正在尝试启动,请稍候...');
window.WebControl.JS_WakeUp('VideoWebPlugin://'); // errorwakeup
this.initCount++;
if (this.initCount < 3) {
setTimeout(function () {
this.initPlugin();
}, 3000);
} else {
$('#playWnd').html('插件启动失败,请检查插件是否安装!');
}
},
windowFullCcreenChange(bFull) {
//
console.log('全屏切换回调', bFull)
cbConnectClose() {
// bNormalClose = false
// JS_DisconnectbNormalClose = true
console.log('cbConnectClose');
oWebControl = null;
},
firstFrameDisplay(iWndIndex, iWidth, iHeight) {
//
console.log('首帧显示回调', iWndIndex, iWidth, iHeight)
},
performanceLack(iWndIndex) {
//
console.log('性能不足回调', iWndIndex)
}
});
this.oWebControl2 = oWebControl;
},
//
init() {
let _that = this;
this.getPubKey(function () {
//
var appkey = "29940726"; //appkey
var secret = 'SkTCnQdFbNW4Z2suNj8P'; //secret
var ip = "192.168.66.13"; //IP
var playMode = 0; //0-1-
var port = 554; //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.oWebControl2.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((res) => {
let width = document.querySelector("#playWnd").offsetWidth;
let height = document.querySelector("#playWnd").offsetHeight;
_that.oWebControl2.JS_Resize(width, height); // resize
console.log('22222222222');
console.log(res);
});
});
},
//
setCallbacks() {
this.oWebControl.JS_SetWindowControlCallback({
cbIntegrationCallBack: this.cbIntegrationCallBack,
});
},
//
cbIntegrationCallBack(oData) {
//
console.log(oData);
},
//
getPubKey(callback) {
this.oWebControl2.JS_RequestInterface({
funcName: "getRSAPubKey",
argument: JSON.stringify({
keyLength: 1024,
}),
})
.then((oData) => {
console.log(oData);
if (oData.responseMsg.data) {
this.pubKey = oData.responseMsg.data;
callback();
}
});
},
//RSA
// setEncrypt(value) {
// var encrypt = new encrypt();
// encrypt.setPublicKey(this.pubKey);
// console.log(encrypt.encrypt(value));
// return encrypt.encrypt(value);
// },
//
getVideoFun(Code) {
let _that = this;
//
var cameraIndexCode = Code; //
var streamMode = 0; //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('44444444444');
console.log(cameraIndexCode);
console.log( _that.oWebControl2);
console.log( _that.oWebControl2.JS_RequestInterface);
_that.oWebControl2.JS_RequestInterface({
funcName: "startPreview",
argument: JSON.stringify({
cameraIndexCode: cameraIndexCode, //
streamMode: streamMode, //
transMode: transMode, //
gpuMode: gpuMode, //GPU
wndId: wndId, //
}),
})
this.play()
.then((res) => {
console.log(res, "res");
console.log('3333333333');
}).catch((err) => {
console.log(err);
});
},
/**
* 播放
*/
play() {
let preUrl = 'rtsp://192.168.66.13:554/openUrl/MXdnCG4' //
const param = {
playURL: preUrl,
// 1 0
mode: 1
}
//
let index = 0
console.log(this.playerArr)
this.player.JS_Play(preUrl, param, index).then(
() => {
//
console.log('播放成功')
//
stopVideoFun() {
this.oWebControl2.JS_RequestInterface({
funcName: "stopAllPreview",
});
},
// ---html
// 使
//
destroyVideoDiv() {
this.oWebControl2.JS_DestroyWnd()
.then((data) => {
console.log("销毁窗口成功");
console.log(data);
})
.catch((err) => {
console.log("销毁窗口失败");
console.log(err);
});
},
// ---
zhuaPicFun() {
this.oWebControl2.JS_RequestInterface({
funcName: "snapShot",
argument: {
name: "D:\test.jpg", //
},
err => {
console.log('播放失败')
console.log(preUrl);
console.info('JS_Play failed:', err)
}
)
});
},
}
}
</script>
<style>

166
src/views/ty/index4.vue

@ -0,0 +1,166 @@
<template>
<v-scale-screen width="1920" height="1080">
<div id="ty">
<div class="main">
<div class="center">
<div id="player" class="item">
<!-- <Video :src="src1" :poster="poster" /> -->
<!-- <video id="myFlvVideo" controls autoplay width="80%" height="200px"></video> -->
<!-- <video class="demo-video" ref="player" muted autoplay></video> -->
</div>
<div class="item">
<!-- <Video :src="src2" :poster="poster" /> -->
</div>
<div class="item">
<!-- <Video :src="src3" :poster="poster" /> -->
</div>
<!-- <div class="item"></div> -->
</div>
</div>
</div>
</v-scale-screen>
</template>
<script>
// import flvjs from "flv.js";
import '@/utils/h5player.min.js'
// api
import * as homeApi from '@/api/home'
export default {
data() {
return {
player: null
}
},
mounted() {
this.$nextTick(() => {
this.initPlayer()
})
this.getVideo()
},
methods: {
/**
* 初始化播放器
*/
initPlayer() {
this.player = new window.JSPlugin({
//
szId: 'player',
// ,H5player.min.jsjs
szBasePath: '../../../src/utils/h5player.min.js'
// // div#play_windowiWidthiHeight
// iWidth: 600,
// iHeight: 400,
// // 4*4
// iMaxSplit: 16,
// iCurrentSplit: 1,
// //
// oStyle: {
// border: '#343434',
// borderSelect: '#FFCC00',
// background: '#000'
// }
})
this.initPlugin()
},
/**
* 事件初始化
*/
initPlugin() {
this.player.JS_SetWindowControlCallback({
windowEventSelect(iWindIndex) {
//
console.log('windowSelect callback: ', iWindIndex)
},
pluginErrorHandler(iWindIndex, iErrorCode, oError) {
//
console.error(`window-${iWindIndex}, errorCode: ${iErrorCode}`, oError)
},
windowEventOver(iWindIndex) {
//
console.log('鼠标移过回调', iWindIndex)
},
windowEventOut(iWindIndex) {
//
console.log('鼠标移出回调', iWindIndex)
},
windowFullCcreenChange(bFull) {
//
console.log('全屏切换回调', bFull)
},
firstFrameDisplay(iWndIndex, iWidth, iHeight) {
//
console.log('首帧显示回调', iWndIndex, iWidth, iHeight)
},
performanceLack(iWndIndex) {
//
console.log('性能不足回调', iWndIndex)
}
})
this.play()
},
/**
* 播放
*/
play() {
let preUrl = 'rtsp://192.168.66.13:554/openUrl/5jhuK3e' //
const param = {
playURL: preUrl,
// 1 0
mode: 1
}
//
let index = 0
console.log(this.playerArr)
console.log(this.player);
this.player.JS_Play(preUrl, param, index).then(
() => {
//
console.log('播放成功')
},
err => {
console.log('播放失败')
console.log(preUrl);
// console.info('JS_Play failed:', err)
console.info(err)
}
)
},
getVideo() {
let that = this
console.log(that);
homeApi.allGetVideo().then(res => {
// get allTimeData
const tmpdata = res.data.returnData
console.log(tmpdata);
// this.day_num = tmpdata.day.noRepeatInNum
// this.week_num_num = tmpdata.week.noRepeatInNum
// this.mon_num = tmpdata.month.noRepeatInNum
// this.year_num = tmpdata.year.noRepeatInNum
// let btdata = new Array();
// let bvdata = new Array();
// tmpdata.foreach(function(item,index){
// console.log(item);
// console.log(index);
// });
});
},
}
}
</script>
<style>
.demo-video {
max-width: 880px;
max-height: 660px;
/* background-image: url(../../../src/utils/h5player.min.js); */
}
</style>

348
src/views/ty/index6.vue

@ -0,0 +1,348 @@
<template>
<v-scale-screen width="1920" height="1080">
<div id="ty">
<div class="main">
<div class="center">
<!-- <el-button @click="begin"></el-button> -->
<div ref="playWnd" :id="containerId" class="flex-1 hidden playWnd"
v-html="oWebControl === null ? playText : ''"></div>
<!--v-resize="DomResize" 是用来播放器窗口自适应的如果不需要可以不添加下面会介绍到-->
</div>
</div>
</div>
</v-scale-screen>
</template>
<script>
// import flvjs from "flv.js";
// import '@/utils/h5player.min.js'
// import $ from "jquery";//jquerynpm----npm i jquery -S
import { WebControl } from 'web-control';
export default {
props: {
// 4
// appkey: {
// type: "String",
// default: "29940726",
// },
// secret: {
// type: "String",
// default: "",
// },
// ip: {
// type: "String",
// default: "",
// },
// port: {
// type: "Number",
// default: 8888,
// },
//
// layout: {
// type: "String",
// default: "1x1",
// },
// 0-1-
// playMode: {
// type: "Number",
// default: 0,
// },
// 0-0-
showToolbar: {
type: Number,
default: 1,
},
//
toolBarButtonIDs: {
type: String,
default: "4098,4097",
},
// 线0-0-
showSmart: {
type: Number,
default: 1,
},
//
buttonIDs: {
type: String,
default: "0,16,256,257,258,259,260,512,515,516,517,768,769",
},
//
cameraIndexCode: {
type: [String, Number],
},
//
refresh: {
type: Number,
},
// id
containerId: {
type: String,
default: "playWnd",
}
},
data() {
return {
oWebControl: null,
plugKey: "",
//
videoParams: {
cameraIndexCode: "", //
streamMode: 0, //0-1-
transMode: 1, //0-UDP1-TCP
gpuMode: 0, //GPU0-1-
wndId: 1, //
},
videoWidth: null,
videoHeight: null,
playText: "启动中...",
initCount: 0, //
href: "",
};
},
created() {
this.getPluginUrl();
this.createdVideo();
},
mounted() {
this.$nextTick(() => {
this.videoWidth = this.$refs.playWnd.offsetWidth;
this.videoHeight = this.$refs.playWnd.offsetHeight;
});
// resize使DIV
window.addEventListener("resize", this.windowResize);
// // scroll使
window.addEventListener("scroll", this.windowScroll);
},
watch: {
//
cameraIndexCode(value) {
if (value) {
this.videoParams.cameraIndexCode = value.trim();
this.videoParams.wndId = -1;
if (this.oWebControl) {
this.previewVideo();
} else {
this.createdVideo();
}
}
},
//
refresh() {
this.destroyeWnd();
setTimeout(() => {
this.createdVideo();
}, 0);
}
},
methods: {
//
getPluginUrl() {
return ''
// getList(1, 999).then(res => {
// if (res.data.code === 200) {
// const data = res.data.data.records;
// data.length
// if (data.length) {
// let existArr = data.filter(item => item.paramKey === "");
// if (existArr.length) {
// this.href = existArr[0].paramValue;
// }
// }
// }
// }).catch(err => {
// //
// console.log(err)
// })
;
},
// +
createdVideo() {
this.initPlugin(() => {
this.previewVideo();
});
},
//
initPlugin(callback) {
this.oWebControl = new WebControl({
szPluginContainer: this.containerId, // id
iServicePortStart: 15900,
iServicePortEnd: 15909,
szClassId: "23BF3B0A-2C56-4D97-9C03-0CB103AA8F11", // IE10使ActiveXclsid
// WebControl
cbConnectSuccess: () => {
this.oWebControl
.JS_StartService("window", {
// WebControl
dllPath: "./VideoPluginConnect.dll",
})
.then(() => {
//
this.oWebControl.JS_SetWindowControlCallback({
//
cbIntegrationCallBack: this.cbIntegrationCallBack,
});
this.oWebControl
.JS_CreateWnd(this.containerId, this.videoWidth, this.videoHeight)
.then(() => {
this.getVersion(callback);
});
});
},
cbConnectError: () => {
// WebControl
this.oWebControl = null;
this.playText = "插件未启动,正在尝试启动,请稍候...";
WebControl.JS_WakeUp("VideoWebPlugin://"); // errorwakeup
this.initCount++;
if (this.initCount < 3) {
setTimeout(() => {
this.initPlugin();
}, 2000);
} else {
this.playText = `
插件启动失败请检查插件是否安装
<a href=${this.href} type="primary" download="视频插件.exe" style='color:#4194fc'>下载地址</a>`;
}
},
cbConnectClose: () => {
this.oWebControl = null;
},
});
},
//
cbIntegrationCallBack() { },
//
init(callback) {
this.getPubKey(() => {
this.oWebControl
.JS_RequestInterface({
funcName: "init",
argument: JSON.stringify({
appkey: '29940726', //APIappkey
secret: this.setEncrypt('SkTCnQdFbNW4Z2suNj8P'), //APIsecret
ip: this.ip, //APIIPz
playMode: this.playMode, //
port: this.port, //
snapDir: "C:\\SnapDir", //
videoDir: "C:\\VideoDir", //
layout: this.layout, //
enableHTTPS: 1, //HTTPS
encryptedFields: "secret", //
showToolbar: this.showToolbar, //
toolBarButtonIDs: this.toolBarButtonIDs,
showSmart: this.showSmart, //
buttonIDs: this.buttonIDs, //
protocol: "hls",
}),
})
.then(() => {
// resizefirefoxDIV
this.oWebControl.JS_Resize(this.videoWidth, this.videoHeight);
if (callback) {
callback();
}
});
});
},
//
getPubKey(callback) {
const params = {
funcName: "getRSAPubKey",
argument: JSON.stringify({ keyLength: 1024 }),
};
this.oWebControl.JS_RequestInterface(params).then((res) => {
if (res.responseMsg.data) {
this.plugKey = res.responseMsg.data;
callback();
}
});
},
// RSA
// setEncrypt(value) {
// const encrypt = new JSEncrypt();
// encrypt.setPublicKey(this.plugKey);
// return encrypt.encrypt(value);
// },
//
previewVideo() {
this.oWebControl.JS_RequestInterface({
funcName: "startPreview",
argument: JSON.stringify(this.videoParams),
});
},
//
showFullScreen() {
this.oWebControl.JS_RequestInterface({
funcName: "setFullScreen",
});
},
// 退
exitFullScreen() {
this.oWebControl.JS_RequestInterface({
funcName: "exitFullScreen",
});
},
windowScroll() {
if (this.oWebControl != null) {
this.oWebControl.JS_Resize(this.videoWidth, this.videoHeight);
}
},
windowResize() {
this.videoWidth = this.$refs.playWnd.offsetWidth;
this.videoHeight = this.$refs.playWnd.offsetHeight;
if (this.oWebControl) {
this.oWebControl.JS_Resize(this.videoWidth, this.videoHeight);
}
},
//
destroyeWnd() {
if (this.oWebControl) {
this.oWebControl.JS_HideWnd();
this.oWebControl.JS_Disconnect().then(() => { });
}
},
//
getVersion(callback) {
if (this.oWebControl) {
this.oWebControl.JS_RequestInterface({
funcName: "getVersion",
}).then(res => {
if (res.responseMsg.code === 0 && res.responseMsg.data === "V1.5.1") {
//JS_CreateWnd
this.init(callback); //
console.log("启动插件成功!");
} else {
this.destroyeWnd();
this.playText = `
插件版本不正确请重新下载版本安装覆盖
<a href=${this.href} type="primary" download="视频插件.exe" style='color:#4194fc'>下载地址</a>`;
}
})
}
},
},
beforeDestroy() {
if (this.oWebControl) {
this.oWebControl.JS_HideWnd();
this.oWebControl
.JS_DestroyWnd({
funcName: "destroyeWnd",
})
.then(() => { });
}
document.removeEventListener("resize", this.windowResize);
document.removeEventListener("scroll", this.windowScroll);
},
}
</script>
<style>
.demo-video {
max-width: 880px;
max-height: 660px;
/* background-image: url(../../../src/utils/h5player.min.js); */
}
</style>

2
vue.config.js

@ -18,7 +18,7 @@ module.exports = {
// devServer: {
// proxy: {
// '/api/*': {
// target: 'http://btgym.xingtongworld.com', //跨域请求的公共地址
// target: 'http://127.0.0.1:15901/imghttp/local/', //跨域请求的公共地址
// changeOrigin: true, //是否开启跨域,值为 true 就是开启, false 不开启
// pathRewrite: {
// '^/api': '' //注册全局路径, 但是在你请求的时候前面需要加上 /api

Loading…
Cancel
Save