在线查询网站收录,中心城网站建设,网络服务投诉平台,莱州做网站的公司vue播放rtsp流视频监控-海康摄像头使用工具vuejsencryptjsWebControl思路解决办法1:弹出新页面vue代码解决办法2:采用组建的方式使用工具vuejsencryptjsWebControl
注:使用海康demo,下载地址:https://open.hikvision.com/download/5c67f20bb254d61550c2f63e?type10 需要注册播放rtsp流视频监控-海康摄像头使用工具vuejsencryptjsWebControl思路解决办法1:弹出新页面vue代码解决办法2:采用组建的方式使用工具vuejsencryptjsWebControl
注:使用海康demo,下载地址:https://open.hikvision.com/download/5c67f20bb254d61550c2f63e?type10 需要注册登录。
思路
基于海康demo在vue上实现,剔除了海康demo的jquery。 vue直接引入jsWebControl会报错!!!直接在index.html里面引入js script srcjs/videojs-contrib-hls.min.js/scriptscript srcjs/jsencrypt.min.js/script解决办法1:弹出新页面vue代码
刚开始将视频窗体放在dialog里面发现无法关闭窗体也找不到元素。最终选择 window.open方式弹出新窗体解决的朋友可以留言。
templatediv classwebControl!--视频窗口展示--div idplayWnd classplayWnd styleleft: 109px; top: 133px;span v-ifloading插件未启动正在尝试启动请稍候.../span/div/div
/templatescript
export default {name: webControl,data: function() {return {loading: false,initCount: 0,pubKey: ,oWebControl: null,id: ,message: {ip: ,port: ,appkey: ,secret: }}},async mounted() {this.id this.getQueryString(name)let res await this.$http.get(’)//从接口请求得到所需要的ip,port,appkey,secretif (res.code 0) {this.message res.data} else {this.$message.error(获取数据失败: res.message)}this.initPlugin()},methods: {//获取路由参数getQueryString(name) {var reg new RegExp((^|) name ([^]*)(|$), i)var r window.location.search.substr(1).match(reg)if (r ! null) return decodeURI(r[2])return null},//预览handelShow() {let that thisvar cameraIndexCode this.id //获取输入的监控点编号值必填var streamMode 0 //主子码流标识0-主码流1-子码流var transMode 1 //传输协议0-UDP1-TCPvar gpuMode 0 //是否启用GPU硬解0-不启用1-启用var wndId -1 //播放窗口序号在2x2以上布局下可指定播放窗口cameraIndexCode cameraIndexCode.replace(/(^\s*)/g, )cameraIndexCode cameraIndexCode.replace(/(\s*$)/g, )that.oWebControl.JS_RequestInterface({funcName: startPreview,argument: JSON.stringify({cameraIndexCode: cameraIndexCode, //监控点编号streamMode: streamMode, //主子码流标识transMode: transMode, //传输协议gpuMode: gpuMode, //是否开启GPU硬解wndId: wndId //可指定播放窗口})})},// 创建播放实例initPlugin() {let that this// eslint-disable-next-line no-undefthat.oWebControl new WebControl({szPluginContainer: playWnd, // 指定容器idiServicePortStart: 15900, // 指定起止端口号建议使用该值iServicePortEnd: 15909,szClassId: 23BF3B0A-2C56-4D97-9C03-0CB103AA8F11, // 用于IE10使用ActiveX的clsidcbConnectSuccess: function() {console.log(插件启动成功)this.loading false// 创建WebControl实例成功that.oWebControl.JS_StartService(window, {// WebControl实例创建成功后需要启动服务dllPath: ./VideoPluginConnect.dll // 值./VideoPluginConnect.dll写死}).then(function() {// 启动插件服务成功that.oWebControl.JS_SetWindowControlCallback({// 设置消息回调cbIntegrationCallBack: that.cbIntegrationCallBack})that.oWebControl.JS_CreateWnd(playWnd, 1000, 600).then(function() {//JS_CreateWnd创建视频播放窗口宽高可设定that.init() // 创建播放实例成功后初始化})},function() {// 启动插件服务失败})},cbConnectError: function() {// 创建WebControl实例失败that.oWebControl nullthis.loading true// eslint-disable-next-line no-undefWebControl.JS_WakeUp(VideoWebPlugin://) // 程序未启动时执行error函数采用wakeup来启动程序that.initCountif (that.initCount 3) {setTimeout(function() {that.initPlugin()}, 3000)} else {that.$confirm(插件启动失败请检查插件是否安装, 提示, {confirmButtonText: 确定,cancelButtonText: 取消,type: warning}).then(() {location.href 插件没有安装则从接口下载VideoWebPlugin.exe插件}).catch(() {this.$message({type: info,message: 已取消删除})})}},cbConnectClose: function() {// 异常断开bNormalClose false// JS_Disconnect正常断开bNormalClose truethat.oWebControl null}})},// 推送消息cbIntegrationCallBack() {// showCBInfo(JSON.stringify(oData.responseMsg))},//初始化init() {let that thisthis.getPubKey(function() {// 请自行修改以下变量值 var appkey that.message.appkey//综合安防管理平台提供的appkey必填var secret that.setEncrypt(that.message.secret) //综合安防管理平台提供的secret必填var ip that.message.ip //综合安防管理平台IP地址必填var playMode 0 //初始播放模式0-预览1-回放var port that.message.port //综合安防管理平台端口若启用HTTPS协议默认443var snapDir D:\\SnapDir //抓图存储路径var videoDir D:\\VideoDir //紧急录像或录像剪辑存储路径var layout 1x1 //playMode指定模式的布局var enableHTTPS 1 //是否启用HTTPS协议与综合安防管理平台交互这里总是填1var encryptedFields secret //加密字段默认加密领域为secretvar showToolbar 1 //是否显示工具栏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.oWebControl.JS_RequestInterface({funcName: init,argument: JSON.stringify({appkey: appkey, //API网关提供的appkeysecret: secret, //API网关提供的secretip: ip, //API网关IP地址playMode: playMode, //播放模式决定显示预览还是回放界面port: port, //端口snapDir: snapDir, //抓图存储路径videoDir: videoDir, //紧急录像或录像剪辑存储路径layout: layout, //布局enableHTTPS: enableHTTPS, //是否启用HTTPS协议encryptedFields: encryptedFields, //加密字段showToolbar: showToolbar, //是否显示工具栏showSmart: showSmart, //是否显示智能信息buttonIDs: buttonIDs //自定义工具条按钮})}).then(function() {that.oWebControl.JS_Resize(1000, 600) // 初始化后resize一次规避firefox下首次显示窗口后插件窗口未与DIV窗口重合问题that.handelShow()})})},//获取公钥getPubKey(callback) {let that thisthat.oWebControl.JS_RequestInterface({funcName: getRSAPubKey,argument: JSON.stringify({keyLength: 1024})}).then(function(oData) {if (oData.responseMsg.data) {that.pubKey oData.responseMsg.datacallback()}})},//RSA加密setEncrypt(value) {let that this// eslint-disable-next-line no-undefvar encrypt new JSEncrypt()encrypt.setPublicKey(that.pubKey)return encrypt.encrypt(value)}}
}
/scriptstyle scoped
.playWnd {margin: 30px 0 0 400px;width: 1000px;/*播放容器的宽和高设定*/height: 600px;
}
/style
解决办法2:采用组建的方式
采用组件引用方式惊喜的发现这种方式初始化时不需要过setWndCover修改定位销毁组件使用JS_DestroyWnd切换视频时先通过stopAllPreview停止所有预览再次startPreview预览