vue3+ts实时播放视频,视频分屏

news/2024/10/28 10:32:47/

使用vue3以及播放视频组件Jessibuca
Jessibuca地址
使用循环个数来实现分屏

效果图,四屏在这里插入图片描述
九屏
在这里插入图片描述

dom代码

<div class="icon"><div class="icon-box"><span class="text">分屏:</span><el-icon class="iconsty" @click="oneVideo" style="margin-right: 24px;" title="单屏"><ele-FullScreen /></el-icon><el-icon class="iconsty" @click="fourVideo" style="margin-right: 24px;" title="四屏"><ele-Menu /></el-icon><el-icon class="iconsty" @click="nightVideo" title="九屏"><ele-Grid /></el-icon></div><div class="right-tetx" @click="allVedio" style="margin-right: 24px;" title="全屏">全屏</div>
</div>
<div class="videobox"><JessibucaDemo ref="JessibucaDemoRef" @click="videoBtn(index, item)" :style="liveStyle" v-for="(item, index) in state.spilt" :key="index" :class="state.videoIndex === index ? 'PlayVideo active' :'PlayVideo'" />
</div>

事件

import { reactive, ref } from 'vue';
const state = reactive({spilt: 1,videoIndex: 0
})
// 分频样式
const liveStyle = computed<any>(() => {let style = { width: '100%', height: '100%' }switch (state.spilt) {case 4:style = { width: '50%', height: '50%' }breakcase 9:style = { width: '33.33%', height: '33.333%' }break}return style
});// 单频
const oneVideo = () => {state.videoIndex = 0state.spilt = 1
}
// 四频
const fourVideo = () => {state.videoIndex = 0state.spilt = 4
}
// 九频
const nightVideo = () => {state.videoIndex = 0state.spilt = 9
}

样式

.icon{display: flex;justify-content: space-between;z-index: 999;color: #000;.icon-box{display: flex;align-items: center;.text{font-size: 20px;}.iconsty{font-size: 20px;cursor: pointer;}}.right-tetx{font-size: 20px;cursor: pointer;}
}
.videobox{height: 70vh;display: flex;width: 100%;align-content: flex-start;justify-content: center;flex-wrap: wrap;
}
// 实时视频
.PlayVideo{position: relative;background-color: #000;.borderBox{z-index: 99999;position: absolute;width: 100% !important;top: 0;left: 0;height: 100% !important;border: 1px solid blue;}
}
.PlayVideo {border: 1px solid #505050;
}
::v-deep .is-active{background-color: rgba(20, 157, 251, 1);color: #fff;
}
.active{border: 2px solid blue !important;
}

全屏事件
下载依赖包
npm i screenfull@6.0.2

// 全屏
import screenfull from 'screenfull'
const allVedio = () => {//获取dom元素节点来实现指定元素全屏展示let el = document.querySelector('.videobox')//screenfull.isEnabled  此方法返回布尔值,判断当前能不能进入全屏if (!screenfull.isEnabled) {return false}//screenfull.toggle 此方法是执行全屏化操作。如果已是全屏状态,则退出全屏screenfull.toggle(el)
}

http://www.ppmy.cn/news/1542573.html

相关文章

Docker:namespace环境隔离 CGroup资源控制

Docker&#xff1a;namespace环境隔离 & CGroup资源控制 Docker虚拟机容器 namespace相关命令ddmkfsdfmountunshare 进程隔离文件隔离 CGroup相关命令pidstatstresscgroup控制 内存控制CPU控制 Docker 在开发中&#xff0c;经常会遇到环境问题&#xff0c;比如程序依赖某个…

Qt元对象系统 —— 属性系统

目录 属性系统 进一步&#xff1a;使用上面的阐述详细讨论如何对对象的属性读写 一个例子 Detailed Descriptions of settings 我们下面要讨论的是Qt元对象系统的第二部分&#xff1a;那就是Qt的属性系统。我们知道大部分的类其实都在现实生活中表达一种属性——我们希望通过…

加密DNS有什么用?

在当今数字化高速发展的时代&#xff0c;网络安全和隐私保护成为人们日益关注的焦点。而加密 DNS作为一种新兴的技术手段&#xff0c;正逐渐发挥着重要的作用。 首先我们先来了解下什么是加密DNS&#xff0c;它究竟是什么&#xff1f; 加密DNS&#xff08;Domain Name System…

Qt的简单布局管理说明

目录 Qt的几个Layout QBoxLayout 一个例子&#xff1a; 一些常见的API QGridLayout 一个例子&#xff1a; API QFormLayout 例子 API QStackedLayout 一些例子 API 其他 QSplitter 一些例子 API 附注 这里不是具体的好看的界面设计教程&#xff0c;但是打算说…

DDei 在线设计器 V1.2.41 版发布

​ DDei 在线设计器 V1.2.41 版本带来了新功能、提升了性能、增强了稳定性、扩展了多个回调函数。 提供了简版布局与之配套的简版控件工具箱和顶部菜单&#xff0c;并支持通过 vue 来扩展菜单。 2.由canvas渲染改为canvshtml混合渲染&#xff0c;提升清晰度和渲染性能&#xf…

Leetcode 3336. Find the Number of Subsequences With Equal GCD

Leetcode 3336. Find the Number of Subsequences With Equal GCD 1. 解题思路2. 代码实现 题目链接&#xff1a;3336. Find the Number of Subsequences With Equal GCD 1. 解题思路 这一题没能自力搞定&#xff0c;挺伤心的&#xff0c;看大佬的代码之后发现思路上是一个非…

使用 python中 pandas 将 Excel 转换为 CSV 文件

在数据处理和分析中&#xff0c;我们经常需要将 Excel 文件转换为 CSV 格式。CSV 文件因其简单、易于处理的特点&#xff0c;广泛用于数据交换。本文将介绍如何使用 wxPython 创建一个简单的图形用户界面&#xff08;GUI&#xff09;&#xff0c;结合 pandas 库&#xff0c;实现…

每天五分钟深度学习框架pytorch:从底层实现一元线性回归模型

本文重点 本节课程我们继续搭建一元线性回归模型,不同的是这里我们不使用pytorch框架已经封装好的一些东西,我们做这个目的是为了更加清楚的看到pytorch搭建模型的本质,为了更好的理解,当然实际中我们还是使用pytorch封装好的一些东西,不要重复造轮子。 模型搭建 #定义…