当前位置: 首页 > news >正文

vue2+jessibuca播放h265视频

文档地址:http://jessibuca.monibuca.com/api.html#background
1,文件放在public中
在这里插入图片描述
2,在html中引入
在这里插入图片描述
3,子组件

<template><div :id="'container' + id"></div>
</template><script>
export default {props: ['url', 'id','index'],data() {return {jessibuca: null}},mounted() {this.initPlayer();},destroyed() {console.log('destroyed')this.clear()},methods: {clear(){console.log('清除',this.id)this.jessibuca.destroy();},initPlayer() {this.jessibuca = null;this.jessibuca = new window.Jessibuca({container: document.getElementById('container' + this.id),videoBuffer :2,decoder: "/decoder.js",isResize: false,autoWasm: true,text: "",loadingText: "请稍等, 视频加载中......",debug: false,useMSE: false,useWCS: false,autoWasm: true,hasAudio: false,operateBtns: {fullscreen: true},// loadingTimeout: 5 + this.index * 0.5});// this.jessibuca.on('audioInfo', function (audioInfo) {//     console.log('audioInfo', audioInfo);// })// this.jessibuca.on('videoInfo', function (videoInfo) {//     console.log('videoInfo', videoInfo);// })// this.jessibuca.on('performance', function (performance) {//     let show = '卡顿'//     if (performance === 2) {//         show = '非常流畅'//     } else if (performance === 1) {//         show = '流畅'//     }//     console.log('性能', show)// })// this.jessibuca.on('kBps', function (kBps) {//     let _kBps = 0//     _kBps = Math.round(kBps)//     console.log('kBps', _kBps)// })},play(url) {// let url = this.url;console.log('url', url);console.log(this.jessibuca)this.jessibuca.play(url).catch((err) => {console.log('err', err);});}}
}
</script>

4,父组件

<template><div class="videoBox"><div v-for="(item, index) in channelList" :key="index" class="item"><player :url="item.url" :ref="'player' + item.id" v-if="item.status" :id="item.id" :index="index" /><div class="notOnline" v-else><div class="imgBox"><img src="@/assets/img/nodata.png"><div>视频未连接</div></div></div></div></div>
</template>
<script>
import player from '@/components/player.vue'
export default {components: { player },data() {return {channelList: [],// 设备+通道信息currentIdList: []}},mounted() {this.getChannel()},destroyed() {},methods: {clearPlayer() {this.currentIdList.map(item => {if (this.$refs['player' + item]) {this.$refs['player' + item][0].clear()}})},// 获取通道信息getChannel() {this.$http.get(`aa`).then(res => {if (res.code == 0) {res.data.list.map(item => {this.channelList.push(item)this.currentIdList.push(item.id)})this.channelList.map((item, index) => {this.getPlay(item, index)})}})},// 获取视频地址getPlay(item, index) {this.$http.get(`bbb`).then(res => {if (res.code == 0) {this.$set(this.channelList[index], 'url', res.data.ws_flv)this.$refs['player' + item.id][0].play(res.data.ws_flv)}})},}
}
</script>

文章转载自:

http://mFqoBhgB.bnfsw.cn
http://DIVGx7W6.bnfsw.cn
http://CryR3WZ2.bnfsw.cn
http://SCc73wcp.bnfsw.cn
http://apq6ff5r.bnfsw.cn
http://9rMTLhZP.bnfsw.cn
http://wNTJyknx.bnfsw.cn
http://m5eAyVQ2.bnfsw.cn
http://SoiET7SY.bnfsw.cn
http://xdgYaKYa.bnfsw.cn
http://XZIQjRwp.bnfsw.cn
http://GjidP9XH.bnfsw.cn
http://i0C40Dif.bnfsw.cn
http://2lQTsXGY.bnfsw.cn
http://jI1TyobC.bnfsw.cn
http://0AAdoMEK.bnfsw.cn
http://QEvGI7SN.bnfsw.cn
http://HvlJ4HCX.bnfsw.cn
http://sBHIRwI2.bnfsw.cn
http://d3tReL1I.bnfsw.cn
http://NX6jkCrU.bnfsw.cn
http://Hir21sah.bnfsw.cn
http://VuMgc9ab.bnfsw.cn
http://4WTzairf.bnfsw.cn
http://N0wEY6MH.bnfsw.cn
http://oq9YXqJw.bnfsw.cn
http://zsh37QB7.bnfsw.cn
http://l97OyKih.bnfsw.cn
http://uSnWH3cY.bnfsw.cn
http://QRcj1Qkp.bnfsw.cn
http://www.dtcms.com/a/377548.html

相关文章:

  • 智普科技推出 Claude 用户平滑迁移方案,GLM-4.5 模型全面开放
  • IIS 部署 asp.net core 项目时,出现500.19、500.31问题的解决方案
  • ASP.NET Core 中的简单授权
  • 可遇不可求的自动化运维工具 | 2 | 实施阶段一:基础准备
  • Golang安装笔记
  • 【记录】Docker|Docker内部访问LInux主机上的Ollama服务
  • MySQL 日期时间类型:从入门到精通的核心指南
  • git 同时推送两个不同平台的版本管理库
  • SoC日志管理
  • 微服务网关全解析:从入门到实践
  • 《sklearn机器学习——数据预处理》类别特征编码
  • #C语言——刷题攻略:牛客编程入门训练(十一):攻克 循环控制(三),轻松拿捏!
  • 深入剖析 Chrome PartitionAlloc 内存池源码原理与性能调优实践
  • Shell 脚本编程:函数
  • C++ STL 容器的一个重要成员函数——`emplace_back`
  • vue3:触发自动el-input输入框焦点
  • python range函数练习题
  • Q2(门座式)起重机司机的理论知识考试考哪些内容?
  • 企业微信消息推送
  • 顺序表:数据结构中的基础线性存储结构
  • 什么是X11转发?
  • OpenCV计算机视觉实战(24)——目标追踪算法
  • 4.2 I2C通信协议
  • Spring Boot 读取 YAML 配置文件
  • 【系统分析师】第20章-关键技术:微服务系统分析与设计(核心总结)
  • SAP-MM:SAP MM模块精髓:仓储地点(Storage Location)完全指南图文详解
  • Shell脚本周考习题及答案
  • 广东省省考备考(第九十六天9.10)——言语(刷题巩固第二节课)
  • Pthread定时锁与读写锁详解
  • Go模块自动导入教学文档