Vue3在PC端接入萤石云监控

参考文档:文档概述 · 萤石开放平台API文档

1.安装依赖

npm i ezuikit-js

2.封装组件

src/components/PlayerVideo/index.vue

<template><div id="video-container" style="width: 100%;"></div>
</template>
<script lang="ts">
import { reactive, getCurrentInstance, toRefs, onMounted, nextTick, defineComponent } from 'vue';
import EZUIKit from 'ezuikit-js';var player = null as any;
export default defineComponent({name: 'PlayerVideo',props: {accessToken: String,play_url: String,},setup(props: any, { emit }: any) {var themeData = {"header": {"color": "#1890ff","activeColor": "#FFFFFF","backgroundColor": "#000000","btnList": [{"iconId": "deviceID","part": "left","defaultActive": 0,"memo": "顶部设备序列号","isrender": 1},{"iconId": "deviceName","part": "left","defaultActive": 0,"memo": "顶部设备名称","isrender": 1},{"iconId": "cloudRec","part": "right","defaultActive": 0,"memo": "云存储","isrender": 0},{"iconId": "rec","part": "right","defaultActive": 0,"memo": "SD卡回放","isrender": 0}]},"footer": {"color": "#FFFFFF","activeColor": "#1890FF","backgroundColor": "#00000021","btnList": [{"iconId": "play","part": "left","defaultActive": 1,"memo": "播放","isrender": 1},{"iconId": "capturePicture","part": "left","defaultActive": 0,"memo": "截屏按钮","isrender": 1},{"iconId": "sound","part": "left","defaultActive": 0,"memo": "声音按钮","isrender": 1},{"iconId": "pantile","part": "left","defaultActive": 0,"memo": "云台控制按钮","isrender": 1},{"iconId": "recordvideo","part": "left","defaultActive": 0,"memo": "录制按钮","isrender": 1},{"iconId": "talk","part": "left","defaultActive": 0,"memo": "对讲按钮","isrender": 1},{"iconId": "zoom","part": "left","defaultActive": 0,"memo": "电子放大","isrender": 1},{"iconId": "hd","part": "right","defaultActive": 0,"memo": "清晰度切换按钮","isrender": 1},{"iconId": "webExpend","part": "right","defaultActive": 0,"memo": "网页全屏按钮","isrender": 1},{"iconId": "expend","part": "right","defaultActive": 0,"memo": "全局全屏按钮","isrender": 1}]}};onMounted(() => {nextTick(() => {initPlayer()});});const { proxy } = getCurrentInstance() as any;const data = reactive({});const initPlayer = async () => {player = new EZUIKit.EZUIKitPlayer({id: 'video-container', // 视频容器ID// accessToken: "at.67jjm3xg1nqavrv3ch6wuhgl3hjzwvly-6t6ynn896j-0ronkpk-ci0ef9om3",// url: "ezopen://open.ys7.com/FA6803244/1.hd.live",accessToken: props.accessToken,url: props.play_url,// simple - 极简版; pcLive-pc直播;pcRec-pc回放;	mobileLive-移动端直播;mobileRec-移动端回放;security - 安防版;voice-语音版;themeData: themeData,})}const destroyPlayer = () => {if (player) {player.stop();player.destroy();player = null;}}return { ...toRefs(data), destroyPlayer }}
})
</script>
<style scoped lang="scss"></style>

3.页面调用

<template><div class="layout-padding"><div class="layout-padding-view layout-padding-auto"><div class="surveillanceVideo"><PlayerVideo v-if="play_url && accessToken" :play_url="play_url" :accessToken="accessToken"ref="playerVideoRef"></PlayerVideo></div></div></div>
</template><script lang="ts">
import { toRefs, reactive, onMounted, defineComponent, getCurrentInstance, onDeactivated, onActivated, onBeforeUnmount, } from 'vue';
import PlayerVideo from '/@/components/PlayerVideo/index.vue';
export default defineComponent({components: {PlayerVideo},setup() {const data = reactive({play_url: "",accessToken: "",});// 页面加载时onMounted(async () => {console.log("onMounted");initPlayer()});onBeforeUnmount(() => {console.log("onBeforeUnmount");destroyPlayer()})onActivated(() => {console.log("onActivated");initPlayer()})onDeactivated(() => {console.log("onDeactivated");destroyPlayer()})const { proxy }: any = getCurrentInstance();const initPlayer = async () => {let res = await proxy.apis.v2DevicesGetdetail({deviceid: "FA6803244",});if (res.code === 200) {data.play_url = res.data.play_urldata.accessToken = res.data.accessToken} else {proxy.$message({message: res.message,type: 'error',});}};const destroyPlayer = () => {proxy.$refs?.playerVideoRef?.destroyPlayer()}return {...toRefs(data),};},
});
</script><style  lang="scss" scoped>
.surveillanceVideo {width: 600px;height: 400px;
}
</style>

4.效果图

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

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

相关文章

快排详解(4种写法:霍尔/挖坑法/双指针/非递归)

//本文所写快排的结果都是从小到大排序 思路 快排就是把数组的第一个值记为key,然后定义两个指针,一个叫begin,一个叫end. begin指针从数组的头部出发,寻找比key大的值;end指针从数组的尾部出发,寻找比key小的值; 然后交换begin和end的值 ......最后,begin和end相遇就停下…

ESP32驱动PCM5102A播放SD卡音频

文章目录 简介模块参数功能框图引脚定义通信接口和通信数据格式通信流程引脚接线ESP32和PCM5102AESP32和SD模块 主要代码spi.hSD.hAudio.h实验效果总结 简介 PCM5102A模块是一款立体声DAC模块、音频数模转换器&#xff0c;内部集成了PCM5102芯片。PCM5102芯片是集成了立体声模…

ProtonBase 教育行业解决方案

01/方案概述 当前&#xff0c;大数据、云计算等技术正加速教育行业的数字化转型&#xff0c;教学模式从线下转向线上&#xff0c;传统教育企业向具有互联网性质的新型教育企业转变。在此背景下&#xff0c;教育企业亟需探索多源数据的融合扩展&#xff0c;以应对复杂的业务场景…

spark读取hbase数据

使用Apache Spark读取HBase数据是一个常见的操作&#xff0c;通常用于大数据处理和分析。Apache Spark 提供了与 HBase 集成的工具&#xff0c;可以通过 Spark-HBase 连接器来实现这一功能。以下是一个详细的步骤指南和示例代码&#xff0c;帮助你使用 Spark 读取 HBase 中的数…

2025年人工智能,自动化与机械工程国际学术会议(AIAME2025)

早鸟通道开启&#xff1a; 2025年人工智能&#xff0c;自动化与机械工程国际学术会议&#xff08;AIAME2025&#xff09; 2025 International Conference on Artificial Intelligence, Automation, and Mechanical Engineering 【重要日期】 早鸟征稿截止日期&#xff1a;…

在SpringBoot当中设置MySQL兼容unicode编码

类似报错 java.sql.SQLException: Unsupported character encoding utf8mb4at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) ~[mysql-connector-j-8.0.31.jar:8.0.31]at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.…

网络技术-不使用K8S情况下哪些方法可搭建服务链编排

在不使用Kubernetes&#xff08;k8s&#xff09;&#xff08;或不使用Docker环境技术的&#xff09;情况下&#xff0c;搭建服务链编排环境需要依赖其他服务编排和容器化技术&#xff0c;或者采用传统的虚拟机和服务管理方法。以下是一些可能的解决方案&#xff1a; 一、使用其…

[C++并发编程] 线程基础

线程发起 最简单的发起一个线程。 void thread_work(std::string str) {std::cout << "str: " << std << std::endl; } //初始化并启动一个线程 std::thread t1(thread, wangzn2016); 线程等待&#xff1a; 线程发起后&#xff0c;可能新的线…

C++ STL 容器系列(三)list —— 编程世界的万能胶,数据结构中的百变精灵

STL系列学习参考&#xff1a; C STL系列__zwy的博客-CSDN博客https://blog.csdn.net/bite_zwy/category_12838593.html 学习C STL的三个境界&#xff0c;会用&#xff0c;明理&#xff0c;能扩展&#xff0c;STL中的所有容器都遵循这个规律&#xff0c;下面我们就按照这三个境…

UE5 打包环境、C++环境安装说明

文章目录 前言一、安装 Visual Studio 及其必装组件1. 下载安装包1.1 方法11.1 方法22. 安装 Visual Studio3. 修改安装位置(可选)4. 勾选必装组件二、打包错误排查1. 错误:Visual Studio 2022 compiler version 14.42.34433 is not a preferred version. Please use the la…

【AI技术赋能有限元分析应用实践】Abaqus有限元分析到深度学习方法应用全过程——汽车刹车片热力耦合分析

目录 一、项目实现介绍**项目背景****项目目标****项目流程概述****技术融合****项目价值** 二、实现流程**Step 1: 分析问题构建方法&#xff0c;寻找主要分析目标&#xff0c;确定初步目标****Step 2: 使用 Abaqus 完成有限元仿真&#xff0c;后处理并保存数据为 odb 格式***…

从0开始linux(38)——线程(1)线程概念

欢迎来到博主专栏&#xff1a;从0开始linux 博主ID&#xff1a;代码小豪 文章目录 进程与线程线程概念线程的优点线程的独立数据 进程与线程 如果要理解线程&#xff0c;那么进程将会时绕不开的点。首先我们回顾一下我们之前在进程章节当中是如何描述进程的&#xff1f; 进程&…

Vue中的计算属性和监听属性

在Vue中&#xff0c;计算属性和监听属性是两种非常有用的功能&#xff0c;它们可以帮助我们更好地管理数据和响应数据的变化。 计算属性 计算属性是基于它们的依赖进行缓存的。只有当依赖发生变化时&#xff0c;计算属性才会重新计算。这使得计算属性非常适合用于执行昂贵的计…

Doge东哥wordpress主题

Doge东哥wordpress主题是一款专为中小型企业设计的WordPress外贸网站模板&#xff0c;它以其现代、专业且用户友好的界面&#xff0c;为企业提供了一个展示产品和服务的理想平台。以下是对该模板的详细描述&#xff1a; 首页设计概览 首页的设计简洁而不失大气&#xff0c;顶…

keil 5. Flash Timeout. Reset the Target and try it again.

使用官方STM32 ST-LINK Utility 烧写软件 KEIL 5, 设置DFP 包支持FLASH烧写算法 Keil 5, Flash Timeout. Reset the Target and try it again.-CSDN博客

MySQL源码编译

华子目录 下载源码包上传并解压安装cmake环境检测make编译make install安装 部署 下载源码包 下载相应源码包mysql5.7编译安装需要boost库&#xff0c;这里官网下载含boost的源码包https://downloads.mysql.com/archives/community/ 上传并解压 [rootmysql-node1 ~]# du -sh …

【Canvas与化学】枣红实心球钙元素图标

【成图】 120*120 大小图 【代码】 <!DOCTYPE html> <html lang"utf-8"> <meta http-equiv"Content-Type" content"text/html; charsetutf-8"/> <head><title>钙元素图标 Draft2</title><style type&qu…

YOLOv8实战无人机视角目标检测

本文采用YOLOv8作为核心算法框架&#xff0c;结合PyQt5构建用户界面&#xff0c;使用Python3进行开发。YOLOv8以其高效的实时检测能力&#xff0c;在多个目标检测任务中展现出卓越性能。本研究针对无人机目标数据集进行训练和优化&#xff0c;该数据集包含丰富的无人机目标图像…

C#里怎么样使用new修饰符来让类智能选择基类函数还是派生类函数?

C#里怎么样使用new修饰符来让类智能选择基类函数还是派生类函数&#xff1f; 在C#里有一个特殊的用法&#xff0c;就是在创建与基类相同的函数时&#xff0c; 如果使用一个new修饰符&#xff0c;就会导致它会根据变量的类型而选择不同的函数运行。 这是一个比较特殊的使用方法&…

私有库gitea安装

一 gitea是什么 Gitea是一款自助Git服务&#xff0c;简单来说&#xff0c;就是可以一个私有的github。 搭建很容易。 Gitea依赖于Git。 类似Gitea的还有GitHub、Gitee、GitLab等。 以下是安装步骤。 二 安装sqilite 参考&#xff1a; 在windows上安装sqlite 三 安装git…