海康视频插件web文档

渲染组件后,调用initPlugin函数,传入一个code数组

<template>
<div :title="name" :id="id" :style="{width:swfWidth+'px',height:swfHeight+'px'}" class="showvideo">
</div>
</template>
<script>
export default {
props: {
name: {
default: ''
},
id: {
default: 'playWnd'
},
swfWidth: {
default: () => 657
},
swfHeight: {
default: () => 400
},
layout: {
default: '1x1'
},
autoPlay: {
default: true
},
},
data() {
return {
oWebControl: undefined,
initCount: 0,
pubKey: "",
cameraIndexCode: "8d6a85f82350402d8c9adc28a6a3dcef",
codes: ['76eb6efb24074827baa326987c379dab'],
//cameraIndexCode: 'ec89aa4c9dd147b39f59132661a40815',
};
},
created() {
//this.initPlugin();
},
mounted() {
let that = this;
this.observeWrapper();
$(window).resize(() => {
if (this.oWebControl != null) {
this.oWebControl.JS_Resize(450, 264);
this.setWndCover();
}
});
$(window).scroll(() => {
if (this.oWebControl != null) {
this.oWebControl.JS_Resize(450, 264);
this.setWndCover();
}
});
}, destroyed() {
if (this.oWebControl != null) {
this.oWebControl.JS_HideWnd();
this.oWebControl.JS_Disconnect().then(
function () {
},
function () {
}
);
}
}, methods: {
close() {
this.$parent.show_playShipin = false;
if (this.oWebControl != null) {
this.oWebControl.JS_HideWnd();
this.oWebControl.JS_Disconnect().then(
function () {
},
function () {
}
);
}
}, //推送消息
cbIntegrationCallBack(oData) {
showCBInfo(JSON.stringify(oData.responseMsg));
}, //监听自身容器大小变化
observeWrapper() {
const ro = new ResizeObserver((entries) => {
for (const entry of entries) {
const cr = entry.contentRect;
this.videoWidth = cr.width;
this.videoHeight = cr.height;
this.oWebControl &&
this.oWebControl.JS_Resize(this.videoWidth, this.videoHeight);
this.oWebControl && this.setWndCover();
}
});
ro.observe(document.querySelector(`#${this.id}`));
},
setWndCover() {
//裁剪插件实例的大小
let iWidth = $(window).width();
let iHeight = $(window).height();
let oDivRect = $(`#${this.id}`).get(0).getBoundingClientRect(); let iCoverLeft = oDivRect.left < 0 ? Math.abs(oDivRect.left) : 0;
let iCoverTop = oDivRect.top < 0 ? Math.abs(oDivRect.top) : 0;
let iCoverRight =
oDivRect.right - iWidth > 0 ? Math.round(oDivRect.right - iWidth) : 0;
let iCoverBottom =
oDivRect.bottom - iHeight > 0
? Math.round(oDivRect.bottom - iHeight)
: 0;
iCoverLeft = iCoverLeft > this.videoWidth ? this.videoWidth : iCoverLeft;
iCoverTop = iCoverTop > this.videoHeight ? this.videoHeight : iCoverTop;
iCoverRight =
iCoverRight > this.videoWidth ? this.videoWidth : iCoverRight;
iCoverBottom =
iCoverBottom > this.videoHeight ? this.videoHeight : iCoverBottom; this.oWebControl.JS_RepairPartWindow(0, 0, 1001, 600);
if (iCoverLeft != 0) {
this.oWebControl.JS_CuttingPartWindow(0, 0, iCoverLeft, 600);
}
if (iCoverTop != 0) {
this.oWebControl.JS_CuttingPartWindow(0, 0, 1001, iCoverTop);
}
if (iCoverRight != 0) {
this.oWebControl.JS_CuttingPartWindow(
1000 - iCoverRight,
0,
iCoverRight,
600
);
}
if (iCoverBottom != 0) {
this.oWebControl.JS_CuttingPartWindow(
0,
600 - iCoverBottom,
1000,
iCoverBottom
);
}
},/**
* @codes:Array
* */
initPlugin(codes) {
let that = this;
this.codes = codes;
this.oWebControl = new WebControl({
szPluginContainer: that.id, // 指定容器id
iServicePortStart: 15900, // 指定起止端口号,建议使用该值
iServicePortEnd: 15909,
szClassId: "23BF3B0A-2C56-4D97-9C03-0CB103AA8F11", // 用于IE10使用ActiveX的clsid
cbConnectSuccess: function () {
that.oWebControl
.JS_StartService("window", {
// WebControl实例创建成功后需要启动服务
dllPath: "./VideoPluginConnect.dll", // 值"./VideoPluginConnect.dll"写死
})
.then(
function () {
console.log("success");
that.oWebControl.JS_SetWindowControlCallback({
// 设置消息回调
cbIntegrationCallBack: that.cbIntegrationCallBack,
});
that.oWebControl
.JS_CreateWnd(that.id, that.swfWidth, that.swfHeight) //JS_CreateWnd创建视频播放窗口,宽高可设定
.then(function () {
console.log("成功222", that);
that.init(codes); // 创建播放实例成功后初始化
});
},
function () {
// 启动插件服务失败
console.log("fail");
}
);
},
cbConnectError: function () {
// 创建WebControl实例失败
console.log(that, "that");
that.oWebControl = null;
that.$message.error("插件未启动,正在尝试启动,请稍候...");
WebControl.JS_WakeUp("VideoWebPlugin://"); // 程序未启动时执行error函数,采用wakeup来启动程序
that.initCount++;
if (that.initCount < 3) {
setTimeout(function () {
that.initPlugin();
}, 3000);
} else {
that.$message.error("插件启动失败,请检查插件是否安装!");
}
},
cbConnectClose: function (bNormalClose) {
// 异常断开:bNormalClose = false
// JS_Disconnect正常断开:bNormalClose = true
console.log("cbConnectClose");
that.oWebControl = null;
},
});
},
init(codes) {
let that = this;
this.getPubKey(function () {
var appkey = "29482144"; //请自行修改为你自己的
var secret = that.setEncrypt("14Rmadov5xWauvjkVYJd"); //请自行修改为你自己的
var ip = "153.99.0.70"; //请自行修改为你自己的
var playMode = 0; //这个是播放模式,0是预览,1是回放
var port = 8111; //请自行修改为你自己的
var snapDir = "D:\\SnapDir";
var videoDir = "D:\\VideoDir";
var layout = that.layout;
var enableHTTPS = 1;
var encryptedFields = "secret";
var showToolbar = 0;
var showSmart = 1;
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,
secret: secret,
ip: ip,
playMode: playMode,
port: port,
snapDir: snapDir,
videoDir: videoDir,
layout: layout,
enableHTTPS: enableHTTPS,
encryptedFields: encryptedFields,
showToolbar: showToolbar,
showSmart: showSmart,
buttonIDs: buttonIDs,
}),
})
.then(function (oData) {
that.oWebControl.JS_Resize(that.swfWidth, that.swfHeight);
for (let i = 0; i < codes.length; i++) {
that.startClickFn(codes[i]);
}
});
});
},
//公钥的获取
getPubKey(callback) {
let that = this;
this.oWebControl
.JS_RequestInterface({
funcName: "getRSAPubKey",
argument: JSON.stringify({
keyLength: 1024,
}),
})
.then(function (oData) {
console.log(oData);
if (oData.responseMsg.data) {
that.pubKey = oData.responseMsg.data;
callback();
}
});
},
setEncrypt(value) {
let encrypt = new JSEncrypt();
encrypt.setPublicKey(this.pubKey);
return encrypt.encrypt(value);
},
startPlay() {
this.autoPlay = true
this.initPluginPlay(this.codes)
},
startClickFn(code) {
var cameraIndexCode = code;
var streamMode = 0;
var transMode = 1;
var gpuMode = 0;
var wndId = -1;
this.oWebControl.JS_RequestInterface({
funcName: "startPreview",
argument: JSON.stringify({
cameraIndexCode: cameraIndexCode,
streamMode: streamMode,
transMode: transMode,
gpuMode: gpuMode,
wndId: wndId,
}),
});
},
stopClickFn() {
if (this.oWebControl && this.oWebControl.JS_RequestInterface) {
this.oWebControl.JS_RequestInterface({
funcName: "stopAllPreview",
});
}
},
des() {
if (this.oWebControl != null) {
this.oWebControl.JS_HideWnd();
this.oWebControl.JS_Disconnect().then(
function () {
},
function () {
}
);
}
}
},
};
</script>
<style lang="scss" scoped>
.showvideo {
width: 657px;
height: 400px;
//border: 1px solid red;
background-color: rgba(0, 0, 0, .3);
border: 1px solid yellow;
display: flex;
justify-content: center;
align-items: center;
position: relative;
}
</style>

vue海康视频播放组件的更多相关文章

  1. Android海康监控视频调用demo

    一. 开发环境 1. 操作系统:windows7(X64) 2. 开发工具:eclipse adt Build: v22.2.1-833290 JDK7 android SDK 3. 客户端设备版本: ...

  2. 海康相机SDK二次开发只有视频无声音问题

    海康SDK相信做企业开发的的同仁,在项目中经常会用到,毕竟使用范围这么广. 本次就开发遇到的奇葩问题来说明一下我们的解决方案. 场景 虽然海康有4200客户端,但是对于高度定制化的项目,肯定不能再使用 ...

  3. vue.js相关UI组件收集

    内容 UI组件 开发框架 实用库 服务端 辅助工具 应用实例 Demo示例 ###UI组件 element ★9689 - 饿了么出品的Vue2的web UI工具套件 Vux ★6927 - 基于Vu ...

  4. C#制作ActiveX控件中调用海康SDK的问题

    事情是这样的,有一台海康威视的摄像头,客户需要一个ActiveX控件嵌入到网页中,通过点击按钮开始录制和结束录制来进行视频的录制和保存,关于海康摄像头的二次开发在此就不多说了,可以参考SDK中的说明. ...

  5. EasyPlayer播放海康大华RTSP流时RTSPClient客户端连接兼容问题的解决

    在之前的博客<EasyPlayer RTSP播放器对RTSP播放地址url的通用兼容修改意见>中,我描述了遇到的一个客户在播放大华某款摄像机时地址不兼容的问题,这不,团队刚刚参考我的这个意 ...

  6. 在做RTSP摄像机H5无插件直播中遇到的对接海康摄像机发送OPTIONS心跳时遇到的坑

    我们在实现一套EasyNVR无插件直播方案时,选择了采用厂家无关化的通用协议RTSP/Onvif接入摄像机IPC/NVR设备,总所周知,Onvif是摄像机的发现与控制管理协议,Onvif用到的流媒体协 ...

  7. 海康SDK JAVA版本调用步骤及问题介绍

    一.前言 本文为海康SDK JAVA版本Demo的介绍,采用Eclipse运行,以及一些问题记录. 海康SDK版本:SDK_Win32 Eclipse版本:Mars2.0 JDK版本:1.8.0_15 ...

  8. 海康相机开发(1) SDK安装和开发

    1.1 安装包获取 从官网下载最新版本的MVS安装包,支持Windows xp.Windows 7.Windows 8.Windows 10的32和64位系统.安装过程默认即可. 官网下载链接:htt ...

  9. iNeuOS工业互联平台,WEB组态(iNeuView)集成rtmp和websocket视频元件,支持海康、大华等摄像头实时显示视频

    目       录 1.      概述... 1 2.      平台演示... 2 3.      硬件摄像头... 2 4.      视频流协议转换管理... 2 5.      组态视频元件 ...

随机推荐

  1. Linux安装Redis步骤和make遇到的坑

    Linux安装Redis服务步骤 1.获取redis资源 ​​​​​​​cd /usr/local wget https://mirrors.huaweicloud.com/redis/redis-6 ...

  2. toFixed()与银行家舍入

    toFixed()与银行家舍入 一直在用toFixed()方法做浮点数的舍入取值,如果只是客户端展示数据是没有多大问题的,但是如果涉及到和后端互交,数据的精度可能会导致接口对接失败,当然了,涉及安全性 ...

  3. 从压测碰到的诡异断连问题聊聊Nginx的连接管理

    本文主要分享一个在压测Nginx反向代理服务过程中碰到的连接异常断开问题,包括问题的定位与复现,最后由这个实际问题引申聊一下Nginx的连接管理. 本博客已迁移至CatBro's Blog,那是我自己 ...

  4. ASP.NET和ASP.NETCore多环境配置对比

    前言 多环境配置应该都很熟悉了,最为常见的便是Debug和Release,例如下图是新建的一个asp.net项目,配置文件展开共有三个文件组成 据我所知,大多公司从来没编辑过Web.Debug.con ...

  5. 发布nuget包的正确姿势---cicd自动打包发布nuget包

    最轻便的发布nuget包方式,方便cicd自动打包发布nuget包 首先新建项目 项目名随便取,这里就叫它GuiH.ClassLibrary 默认即可,需要改目标版本时,等创建好再改 项目创建好了 随 ...

  6. Mozi.HttpEmbedded嵌入式Web服务器

    Mozi.HttpEmbedded 嵌入式Web服务器 项目介绍 Mozi.HttpEmbedded是一个基于.Net构建的嵌入式Web服务器,为.Net App提供web服务功能. 嵌入式的目标不是 ...

  7. JS获取Cookie失败

    项目开发日记-bug多多篇(1) 在做评论功能的时候遇到了一个很无厘头的错误,我的思路是参照点赞功能,用Ajax技术异步完成评论信息的传输,然后展示在页面上. 那么在提交评论信息的同时,要连着用户名, ...

  8. Kafka生成消息时的3种分区策略

    摘要:KafkaProducer在发送消息的时候,需要指定发送到哪个分区, 那么这个分区策略都有哪些呢? 本文分享自华为云社区<Kafka生产者3中分区分配策略>,作者:石臻臻的杂货铺. ...

  9. 如何实现 antd table 自动调整可视高度(纵向滚动条,scrollY)

    一.事情的起因 最近在做的项目中有大量的表格,正常的表格高度是没有限制的,数据量很大的时候会出现表格内容以及分页信息超出可视窗口, 为了查看超出的部分就需要滚动页面但是这样就会把查询条件等信息滚出可视 ...

  10. [AcWing 36] 合并两个排序的链表

    点击查看代码 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * L ...