Browse Source

海康web视频插件处理5和优化代码2

lite
‘daijinzheng@xingtongworld.com’ 3 years ago
parent
commit
b4055d5ccc
  1. 2
      src/api/home.js
  2. 285
      src/views/ty/index.vue

2
src/api/home.js

@ -59,7 +59,7 @@ export function allTsgInfoDatas(param) {
export function allGetVideo(param) {
return request({
url: 'http://www.stadium.com/index.php?s=/api/video.video/getVideo',
url: 'http://192.168.66.16/index.php?s=/api/video.video/getVideo',
method: 'post',
param,
})

285
src/views/ty/index.vue

@ -112,7 +112,7 @@ import $ from "jquery";
// import Video from '../../components/btgym/Video.vue'
export default {
components: {
},
data() {
return {
@ -128,7 +128,11 @@ export default {
// this.$nextTick DOM使DOM
this.$nextTick(() => {
this.initPlugin();
this.initPlugin2();
this.initPlugin3();
});
},
mounted() {
@ -145,26 +149,26 @@ export default {
this.addNumber(0, 234098, 'insv')
this.addNumber(0, 234098, 'insv2')
this.addNumber(0, 234098, 'insv3')
// this.getVideo()
if (flvjs.isSupported()) {
let video = this.$refs.player
if (video) {
this.player = flvjs.createPlayer({
type: "flv",
isLive: true,
url: `rtmp://58.200.131.2:1935/livetv/hunantv`
});
this.player.attachMediaElement(video);
try {
this.player.load();
this.player.play();
} catch (error) {
console.log(error);
}
}
}
this.getVideo()
// if (flvjs.isSupported()) {
// let video = this.$refs.player
// if (video) {
// this.player = flvjs.createPlayer({
// type: "flv",
// isLive: true,
// url: `rtmp://58.200.131.2:1935/livetv/hunantv`
// });
// this.player.attachMediaElement(video);
// try {
// this.player.load();
// this.player.play();
// } catch (error) {
// console.log(error);
// }
// }
// }
},
methods: {
ty_bar1() {
@ -696,8 +700,17 @@ export default {
console.log(that);
homeApi.allGetVideo().then(res => {
// get allTimeData
const tmpdata = res.data.returnData
console.log(res);
const tmpdata = res.data.videoData
console.log(tmpdata);
this.decode(tmpdata)
console.log(this.decode(tmpdata));
let baseviode = this.decode(tmpdata)
this.decode(baseviode)
console.log(this.decode(baseviode));
let baseviodejson = this.decode2(baseviode)
var jsonParseJson = JSON.parse(baseviodejson);
console.log(jsonParseJson);
// this.day_num = tmpdata.day.noRepeatInNum
// this.week_num_num = tmpdata.week.noRepeatInNum
// this.mon_num = tmpdata.month.noRepeatInNum
@ -712,6 +725,24 @@ export default {
});
},
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(''));
},
decode2(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() {
@ -737,7 +768,7 @@ export default {
oWebControl.JS_CreateWnd('playWnd').then(() => {
//JS_CreateWnd
_that.init(); //
});
},
() => {
@ -773,6 +804,124 @@ export default {
});
this.oWebControl2 = oWebControl;
},
initPlugin2() {
let _that = this;
const oWebControl = new window.WebControl({
szPluginContainer: 'playWnd2', // id
iServicePortStart: 15900, // 使
iServicePortEnd: 15900,
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('playWnd2').then(() => {
//JS_CreateWnd
_that.init2(); //
});
},
() => {
//
console.log('启动插件服务失败');
}
)
.catch((err) => {
console.log(err);
});
},
cbConnectError() {
// WebControl
console.log('xxx');
oWebControl = null;
$('#playWnd2').html('插件未启动,正在尝试启动,请稍候...');
window.WebControl.JS_WakeUp('VideoWebPlugin://'); // errorwakeup
this.initCount++;
if (this.initCount < 3) {
setTimeout(function () {
this.initPlugin();
}, 3000);
} else {
$('#playWnd2').html('插件启动失败,请检查插件是否安装!');
}
},
cbConnectClose(bNormalClose) {
// bNormalClose = false
// JS_DisconnectbNormalClose = true
console.log('cbConnectClose');
oWebControl = null;
},
});
this.oWebControl2 = oWebControl;
},
initPlugin3() {
let _that = this;
const oWebControl = new window.WebControl({
szPluginContainer: 'playWnd3', // id
iServicePortStart: 15900, // 使
iServicePortEnd: 15900,
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('playWnd3').then(() => {
//JS_CreateWnd
_that.init3(); //
});
},
() => {
//
console.log('启动插件服务失败');
}
)
.catch((err) => {
console.log(err);
});
},
cbConnectError() {
// WebControl
console.log('xxx');
oWebControl = null;
$('#playWnd3').html('插件未启动,正在尝试启动,请稍候...');
window.WebControl.JS_WakeUp('VideoWebPlugin://'); // errorwakeup
this.initCount++;
if (this.initCount < 3) {
setTimeout(function () {
this.initPlugin();
}, 3000);
} else {
$('#playWnd3').html('插件启动失败,请检查插件是否安装!');
}
},
cbConnectClose(bNormalClose) {
// bNormalClose = false
// JS_DisconnectbNormalClose = true
console.log('cbConnectClose');
oWebControl = null;
},
});
this.oWebControl2 = oWebControl;
},
//
init() {
let _that = this;
@ -819,6 +968,96 @@ export default {
});
});
},
init2() {
let _that = this;
this.getPubKey(function () {
//
var appkey = "29940726"; //appkey
var secret = _that.setEncrypt("SkTCnQdFbNW4Z2suNj8P"); //secret
var ip = "192.168.66.13"; //IP
var playMode = 0; //0-1-
var port = 443; //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: "init2",
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("#playWnd2").offsetWidth;
let height = document.querySelector("#playWnd2").offsetHeight;
_that.oWebControl2.JS_Resize(width, height); // resize
console.log(oData);
_that.getVideoFun('05edddc148b141c5930301af43154942')
});
});
},
init3() {
let _that = this;
this.getPubKey(function () {
//
var appkey = "29940726"; //appkey
var secret = _that.setEncrypt("SkTCnQdFbNW4Z2suNj8P"); //secret
var ip = "192.168.66.13"; //IP
var playMode = 0; //0-1-
var port = 443; //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: "init3",
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("#playWnd3").offsetWidth;
let height = document.querySelector("#playWnd3").offsetHeight;
_that.oWebControl2.JS_Resize(width, height); // resize
console.log(oData);
_that.getVideoFun('05edddc148b141c5930301af43154942')
});
});
},
//
setCallbacks() {
this.oWebControl.JS_SetWindowControlCallback({

Loading…
Cancel
Save