海康监控视频非分屏需求,一个页面引用多个视频组件;

js文件位置

在这里插入图片描述

index.html 引入js文件

   //根据自己路径引入哈<script src="static/haiKangWeb3.0/jquery-1.7.1.min.js"></script><script type="text/javascript" id="videonode" src="static/haiKangWeb3.0/webVideoCtrl.js"></script>

在这里插入图片描述

新建子组件videoMonitorings.vue

//子组件
<template><div class="video"><div :id="videoId" class="plugin"/></div>
</template><script>
import {WebVideo} from "../../../public/static/haiKangWeb3.0/webVideo.js";
import {message} from "@/utils/message";
import {reactive,onMounted,onBeforeUnmount,onUnmounted,toRefs,ref,watch
} from "vue";export default {name: "index",props: {videoId: {type: String},hkvInfo: {type: Object || Array,require: true},},// emits:['changeFlag'],setup(props,{emit}) {const {dataList} = toRefs(props);const hkvInfo = ref({});const videoId = ref();const channels = ref([])const state = reactive({webVideo: "",web: {},});watch(props.hkvInfo, (newVal, oldvalue) => {if (newVal) {console.log('newVal', newVal)const web = new WebVideo();hkvInfo.value = newValvideoId.value = newVal.id;let t = newVal.loadingTime || 1000setTimeout(() => {initS();}, t)} else {initS();}}, {deep: true,immediate: true,})const initS = () => {// 初始化WebVideoCtrl.I_InitPlugin({bWndFull: true, //是否支持单窗口双击全屏,默认支持 true:支持 false:不支持iWndowType: 1,// 画面分割数 1 就是1*1   2就是2*2cbSelWnd: function (xmlDoc) {//此属性是窗口分割切换窗口时触发//clickStartRealPlay();// console.log("当前选择的窗口编号是1");},cbInitPluginComplete: function () {WebVideoCtrl.I_InsertOBJECTPlugin(videoId.value).then(() => {// 检查插件是否最新WebVideoCtrl.I_CheckPluginVersion().then((bFlag) => {if (bFlag) {let str = "检测到新的插件版本,双击开发包目录里的HCWebSDKPlugin.exe升级!"message(str, {type: "warning"});}});},() => {let str1 = "插件初始化失败,请确认是否已安装插件;如果未安装,请双击开发包目录里的HCWebSDKPlugin.exe安装!";message(str1, {type: "warning"});});},});setTimeout(() => {let cw = Math.round(document.body.clientWidth / 1920);let ch = Math.round(document.body.clientHeight / 1080);let width = parseInt((hkvInfo.value.width * cw), 10);let height = parseInt((hkvInfo.value.height * ch), 10);if (height <= 200) {height = 200;}if (height <= 200) {height = 200;}let w1 = (window.innerWidth - document.getElementById(videoId.value).offsetLeft) - 1500;let w2 = document.getElementById(videoId.value).clientHeight;console.log('00000===>', width, height);// 对窗口大小重新规划WebVideoCtrl.I_Resize(width,height);setVideoWindowResize(videoId.value, width, height);clickLogin();}, 2000);}// 根据设备宽高和windowchange设置窗口大小const setVideoWindowResize = (pid, width, height) => {document.getElementById(pid).style.width = width + 'px';document.getElementById(pid).style.height = height + 'px';}// 登录const clickLogin = () => {var szIP = hkvInfo.value.ip,szPort = hkvInfo.value.port,szUsername = hkvInfo.value.username,szPassword = hkvInfo.value.password;const iRet = WebVideoCtrl.I_Login(szIP, 1, szPort, szUsername, szPassword, {timeout: 3000,success: function (xmlDoc) {setTimeout(function () {setTimeout(function () {getChannelInfo();}, 1000);getDevicePort();}, 10);},error: function (err) {console.log("登录-err===>", err);},});if (iRet === -1) {console.log(this.szDeviceIdentify + " 已登录过!");// 登录过直接进行预览clickStartRealPlay();}}const getDevicePort = () => {var szDeviceIdentify = hkvInfo.value.ip;if (null == szDeviceIdentify) {return;}WebVideoCtrl.I_GetDevicePort(szDeviceIdentify).then((oPort) => {console.log("152获取端口", oPort);});}const getChannelInfo = () => {let that = this;var szDeviceIdentify = hkvInfo.value.ip + '_' + hkvInfo.value.port;if (null == szDeviceIdentify) {return;}console.log('szDeviceIdentify==============>', szDeviceIdentify);// 模拟通道WebVideoCtrl.I_GetAnalogChannelInfo(szDeviceIdentify, {success: function (xmlDoc) {clickStartRealPlay();},error: function (oError) {console.log(szDeviceIdentify + "模拟通道", oError.errorCode, oError.errorMsg);}});// 数字通道WebVideoCtrl.I_GetDigitalChannelInfo(szDeviceIdentify, {success: function (xmlDoc) {clickStartRealPlay();},error: function (oError) {console.log(szDeviceIdentify + " 数字通道", oError.errorCode, oError.errorMsg);}});}// 开始预览const clickStartRealPlay = (iStreamType) => {var g_iWndIndex = 0;var oWndInfo = WebVideoCtrl.I_GetWindowStatus(g_iWndIndex) || null;var szDeviceIdentify = hkvInfo.value.ip + '_' + hkvInfo.value.port,iChannelID = 1,bZeroChannel = false;if ("undefined" === typeof iStreamType) {iStreamType = 1;}if (null == szDeviceIdentify) {return;}var startRealPlay = function () {WebVideoCtrl.I_StartRealPlay(szDeviceIdentify, {iStreamType: iStreamType,iChannelID: iChannelID,bZeroChannel: bZeroChannel,success: function () {WebVideoCtrl.I_Logout(szDeviceIdentify);console.log("开始预览成功!");},error: function (oError) {// that.$message.error(szDeviceIdentify+"开始预览失败!");console.log(szDeviceIdentify + "开始预览失败!");},});};if (oWndInfo != null) {// 已经在播放了,先停止WebVideoCtrl.I_Stop({success: function () {startRealPlay();}});} else {startRealPlay();}}// 停止预览const clickStopRealPlay = () => {WebVideoCtrl.I_Stop({success: function () {console.log("停止预览成功!");},error: function (oError) {console.log(" 停止预览失败!");},});}const loginOut = () => {const szDeviceIdentify = hkvInfo.value.ip + "_" + hkvInfo.value.port;WebVideoCtrl.I_Logout(szDeviceIdentify);}const stopAllPlay = () => {WebVideoCtrl.I_StopAllPlay();}const breakDom = () => {WebVideoCtrl.I_DestroyPlugin()}const viewReload = () => {window.location.reload()}onMounted(() => {});onBeforeUnmount(() => {loginOut();stopAllPlay();window.removeEventListener(viewReload());});onUnmounted(() => {setTimeout(() => {breakDom();}, 100)})return {loginOut,stopAllPlay,breakDom,hkvInfo,initS,viewReload,channels,clickLogin,clickStopRealPlay,clickStartRealPlay,setVideoWindowResize,getChannelInfo,getDevicePort,...toRefs(state)};}
};
</script><style scoped lang="scss">
.video {width: 100%;height: 100%;//position: relative;::v-deep(#divPlugin) {width: 100%;height: 100%;//position: absolute;z-index: -1 !important;}::v-deep(#divPlugin1) {width: 100%;height: 100%;//position: absolute;z-index: -1 !important;}::v-deep(#divPlugin2) {width: 100%;height: 100%;//position: absolute;z-index: -1 !important;}::v-deep(#divPlugin3) {width: 100%;height: 100%;//position: absolute;z-index: -1 !important;}::v-deep(#divPlugin4) {width: 100%;height: 100%;//position: absolute;z-index: -1 !important;}
}
</style>

父组件index.vue 引用 子组件

//index.vue
<template><div class="main-content"><div class="video-content">//单个使用<!--      <div class="canvas-contaniner"   >--><!--        <div class="videobox">--><!--          <videoMonitorings :hkvInfo="dataList.hkvInfo01" class="video" :videoId="dataList.hkvInfo01.id" ></videoMonitorings>--><!--        </div>--><!--      </div>-->//多个使用<div class="canvas-contaniner" v-for="(item,index) in dataListRef" :key="index"><div class="videobox"><videoMonitorings :hkvInfo="item" class="video" :videoId="item.id"></videoMonitorings></div></div></div></div>
</template>
<script setup lang="ts">import {ref, reactive, onMounted, onBeforeUnmount} from "vue";import {WebVideo} from "../../../public/static/haiKangWeb3.0/webVideo.js";import videoMonitorings from "./videoMonitorings.vue";const loading = ref(false);const dialogVisible = ref(false);/*
* @以上hkList配置中 注意 loadingTime 和 id;其中loadingTime 建议和上一个时间间隔4S以上,id是动态加载生成填充的DOM树结构;
* 如果间隔时间不够 或DOM的ID一样 可能出现画面加载不出来、画面覆盖重叠等情况;通过配置这2个参数可以避免这样多个摄像头只需要 增加 hkList的配置项即可;
* */
//填入自己ip地址
const dataListRef = ref([{ip: "", //IP地址port: "", //端口号username: "",password: "",iChannelID: 1,loadingTime: "1000",width: "805",height: "375",type: "camera01",id: "divPlugin1",},{ip: "", //IP地址port: "", //端口号username: "",password: "",deviceport: "",iChannelID: 1,//通道IDloadingTime: "5000",width: "805",height: "375",type: "camera02",id: "divPlugin2",},{ip: "", //IP地址port: "", //端口号username: "",password: "",iChannelID: 1,loadingTime: "10000",width: "805",height: "375",type: "camera03",id: "divPlugin3",},{ip: "", //IP地址port: "", //端口号username: "",password: "",iChannelID: 1,loadingTime: "15000",width: "805",height: "375",type: "camera04",id: "divPlugin4",}
])//单个.
const dataList = ref({hkvInfo01: {ip: "", //IP地址port: "", //端口号username: "",password: "",deviceport: "",iChannelID: 1,//通道IDloadingTime: "1000",// 多视频窗口睡眠加载时长。同时多个加载会卡死或不显示width: "805",height: "375",type: "camera01",id: "divPlugin1",},hkvInfo02: {ip: "", //IP地址port: "", //端口号username: "",password: "",iChannelID: 1,loadingTime: "5000",width: "805",height: "375",type: "camera02",id: "divPlugin2",},
});onMounted(() => {})
</script>
<style lang="scss" scoped>
.main-content {margin: 24px 24px 0 !important;
}.video-content {display: flex;justify-content: flex-start;flex-wrap: wrap;position: relative;width: 100%;height: 85vh;.canvas-contaniner {width: 49%;height: 49%;padding: 10px;position: relative;display: flex;justify-content: center;align-items: center;padding: 3px;overflow: hidden;//background: red;}.videobox {display: flex !important;justify-content: center;align-items: center !important;width: 100% !important;height: 100% !important;font-size: 30px;color: #fff;position: relative !important;//left: 20px;background: black;//border: 1px solid red;overflow: hidden;//background-color:black;.video {width: 100% !important;height: 100% !important;object-fit: fill;background-color: #000;}}.loading {display: flex;justify-content: center;align-items: center;width: 100%;height: 100%;font-size: 30px;color: #fff;position: absolute;background: black;}
}</style>

运行效果图如下:
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.pswp.cn/pingmian/87589.shtml
繁体地址,请注明出处:http://hk.pswp.cn/pingmian/87589.shtml
英文地址,请注明出处:http://en.pswp.cn/pingmian/87589.shtml

如若内容造成侵权/违法违规/事实不符,请联系英文站点网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Policy Gradient【强化学习的数学原理】

目录 policy 与表格方式的区别&#xff1a; metric to define optimal policies 1. weighted averge 2. the average reward 问题&#xff1a; 梯度计算 如何理解policy-gradient&#xff1f; policy gradient与表格方式(value based)的区别&#xff1a; policy 通过参…

【深圳大学机器学习】实验一:PCA算法

实验目的 1、实现PCA算法的人脸重构&#xff0c;即用20,40,60,80,...,160个投影来重构图像的效果。 2、实现PCA算法的人脸识别&#xff0c;给出不少于三个人脸数据库上 10,20,30,...,160维的人脸识别识别率&#xff0c;并打印出识别率变化曲线图。 3、用PCA用来进行人脸图像…

编程中的英语

case this are mixed case version case在这里表示大小写&#xff1f;为什么case可以表示大小写的含义&#xff1f; “case”在这里的含义 在句子“This are mixed case version”中&#xff0c;“case”确实表示“大小写”&#xff0c;用于描述字母的形式&#xff08;大写字母…

LabVIEW开发关节轴承试验机

LabVIEW通过NI硬件&#xff08;CompactRIO 实时控制器、FPGA 模块等&#xff09;与模块化软件设计的结合&#xff0c;实现试验参数采集、多工况控制、数据存储的并行处理&#xff0c;体现LabVIEW 在工业自动化中对多任务并发场景的高效支持能力。 ​ 应用场景 关节轴承试验机…

【Linux庖丁解牛】— 动静态库的制作和使用!

1. 什么是库库是写好的现有的&#xff0c;成熟的&#xff0c;可以复⽤的代码。现实中每个程序都要依赖很多基础的底层库&#xff0c;不可能 每个⼈的代码都从零开始&#xff0c;因此库的存在意义⾮同寻常。 本质上来说库是⼀种可执⾏代码的⼆进制形式&#xff0c;可以被操作系统…

Hadoop集群启动 (ZooKeeper、HDFS、YARN、Hbase)

一、启动ZooKeeper集群 sh /opt/modules/zookeeper-3.4.14/bin/zkServer.sh start[hadoopcentos01 ~]$ sh /opt/modules/zookeeper-3.4.14/bin/zkServer.sh start ZooKeeper JMX enabled by default Using config: /opt/modules/zookeeper-3.4.14/bin/../conf/zoo.cfg Startin…

React Hooks全面解析:从基础到高级的实用指南

React Hooks全面解析&#xff1a;从基础到高级的实用指南 React Hooks自2018年16.8版本引入以来&#xff0c;彻底改变了React组件的开发方式。** Hooks使函数组件获得了与类组件同等的表达能力&#xff0c;同时简化了代码结构&#xff0c;提升了可维护性**。本文将系统介绍Rea…

LINUX75 LAMP

LAMP 环境 yum NetworkManager systemctl status firewalld setenforce 0 Last login: Fri Jul 4 19:21:47 2025 from 192.168.235.1 [rootweb ~]# cd /usr/local/apache2/conf/ [rootweb conf]# ls extra httpd.conf httpd.conf.bak magic mime.types original [root…

cloudflare配合github搭建免费开源影视LibreTV一个独享视频网站 详细教程

一、项目简介 LibreTV 是一个开源的 IPTV/影视聚合前端项目&#xff0c;支持 M3U 播放列表、EPG 电子节目单等。它本身是纯前端项目&#xff0c;非常适合用 GitHub Pages Cloudflare 免费托管。 二、准备工作 GitHub 账号 注册并登录 GitHub Cloudflare 账号 注册并登录 …

Linux/Unix进程概念及基本操作(PID、内存布局、虚拟内存、环境变量、fork、exit、wait、exec、system)

进程 文章目录 进程I 进程基本概念1、进程和程序2、进程号和父进程号3、进程内存布局4、虚拟内存管理&#xff08;1&#xff09;程序的两种局部性&#xff08;2&#xff09;虚拟内存的规划&#xff08;3&#xff09;虚拟内存的优点 5、栈和栈帧6、命令行参数argc和argv7、环境变…

0基础学Python系列【25】 单元测试入门教程

大家好,欢迎来到Python学习的第三站!🎉 这部分会涉及一些Python的进阶技术,虽然不一定是必需的,但学会这些,你会觉得编程更得心应手。 本章要学什么? Python调试器(pdb)装饰器lambda函数代码性能分析单元测试入门 —— 今天讲这里听起来有点多?别担心,我们慢慢来,…

iOS常见内存错误码

一、经典十六进制错误码0xDEADBEEF&#xff08;EXC_BAD_ACCESS&#xff09; 含义&#xff1a;野指针访问&#xff08;访问已释放的内存地址&#xff09;。 记忆点&#xff1a;“DEAD BEEF” 可理解为 “死亡牛肉”&#xff0c;象征指针指向的内存已 “死亡”。 触发场景&#x…

CSS01:CSS的快速入门及优势

CSS快速入门 style 练习格式&#xff1a; <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><title>CSS</title><!-- 规范,<style>可以编写css代码,每一个声明最好用分号结尾语法&#xff1a;…

springsecurity5配置之后启动项目报错:authenticationManager cannot be null

目录 配置代码 报错信息 解决办法 配置代码 下面的配置为响应式的配置方式 //这个配置只是配置springboot admin的一个例子,具体的配置可能比较复杂 @EnableWebFluxSecurity public class SecurityConfig {private final AdminServerProperties adminServer;public Securi…

攻防世界-Rerverse-game

知识点 1.ida逆向 2.函数分析逆向 步骤 用Exeinfo打开&#xff0c;为32位exe文件。 方法一&#xff1a; 玩游戏通关&#xff0c;根据游戏规则&#xff0c;m1&#xff0c;n依次为1到8即可得到flag。 方法二&#xff1a; 用32位IDA打开 ctrlF搜索main&#xff0c;点击_main,…

openEuler 24.03 全流程实战:用 Ansible 5 分钟部署分布式 MinIO 高可用集群

目录 0 | 为什么要写这篇教程&#xff1f; 1 | 准备工作 1.1 控制节点手工下载 MinIO 1.2 SSH 互信&#xff08;可跳过&#xff0c;本教程已有互信&#xff09; 1.3 安装 Ansible & SELinux 依赖 2 | 项目目录 3 | Inventory hosts.ini 4 | 变量文件 group_vars/al…

最左匹配原则

导读&#xff1a; 首先创建一张 test 表&#xff0c;并插入一些数据&#xff1a; CREATE TABLE test ( id int(11) NOT NULL AUTO_INCREMENT COMMENT 主键, a int(11) NOT NULL, b int(11) NOT NULL, c int(11) NOT NULL, d int(11) NOT NULL, PRIMARY KEY (id), KEY idx_abc …

MySQL 8.0 OCP 1Z0-908 题目解析(17)

题目65 Choose two. Which two are characteristics of snapshot-based backups? □ A) The frozen file system can be cloned to another virtual machine immediately into active service. □ B) There is no need for InnoDB tables to perform its own recovery when re…

Level2_12小球与挡板(移动+反弹)

一、前引 #已经学习完了: #1.数据结构&#xff1a;集合、元组、字典 #2.函数 #3.类和对象 #4.继承与多态 #1.规划编程项目: #&#xff08;1&#xff09;你想做什么什么样功能的项目&#xff1f; # 接小球游戏,碰到挡板时自动反弹 #&#xff08;2&#xff09;功能有哪些&#x…

win11 2025开机禁用微软账号登录,改本地用户登录,品牌预装机福音

今天开箱了品牌商出厂系统一台华为笔记本&#xff0c;开机提示连接wifi并需要登录微软账号&#xff0c;其中过程实在缓慢&#xff0c;而且老是提示自动更新&#xff0c;速度太慢了&#xff0c;等的花都谢了&#xff0c;进到桌面大概得要30-40分钟&#xff0c;还不如本地用户登录…