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

vue实现flv格式视频播放

公司项目需要实现摄像头实时视频播放,flv格式的视频。先百度使用flv.js插件实现,但是两个摄像头一个能放一个不能放,没有找到原因。(开始两个都能放,后端更改地址后不有一个不能放)但是在另一个系统上是可以播放的。使用的是jessibuca.js

jessibuca.js实现视频播放

1、下载jessibuca.js包

在这里插入图片描述
这三个文件需要直接放到public文件夹里,不能在添加文件夹放置。

2、创建VideoPlayer.vue文件

<template><div id="container" ref="container"></div>
</template>
<script>
export default {name: 'DemoPlayer',props: {videoUrl: {type: String,default: ''}},data() {return {jessibuca: null,version: '',wasm: false,vc: 'ff',playing: false,quieting: true,loaded: false, // muteshowOperateBtns: false,showBandwidth: false,err: '',speed: 0,performance: '',volume: 1,rotate: 0,useWCS: false,useMSE: true,useOffscreen: false,recording: false,recordType: 'webm',scale: 0}},mounted() {this.create()window.onerror = (msg) => (this.err = msg)},unmounted() {this.jessibuca.destroy()},methods: {create(options) {options = options || {}this.jessibuca = new window.Jessibuca(Object.assign({container: this.$refs.container,videoBuffer: 0.2, // Number(this.$refs.buffer.value), // 缓存时长isResize: false,useWCS: this.useWCS,useMSE: this.useMSE,text: '',// background: "bg.jpg",loadingText: '疯狂加载中...',// hasAudio:false,debug: true,supportDblclickFullscreen: true,showBandwidth: this.showBandwidth, // 显示网速operateBtns: {fullscreen: this.showOperateBtns,screenshot: this.showOperateBtns,play: this.showOperateBtns,audio: this.showOperateBtns},vod: this.vod,forceNoOffscreen: !this.useOffscreen,isNotMute: true,timeout: 10},options))var _this = thisthis.jessibuca.on('pause', function () {console.log('on pause')_this.playing = false})this.jessibuca.on('play', function () {console.log('on play')_this.playing = true})this.jessibuca.on('mute', function (msg) {console.log('on mute', msg)_this.quieting = msg})this.jessibuca.on('error', function (error) {console.log('error', error)})this.jessibuca.on('performance', function (performance) {var show = '卡顿'if (performance === 2) {show = '非常流畅'} else if (performance === 1) {show = '流畅'}_this.performance = show})this.jessibuca.on('play', () => {this.playing = truethis.loaded = truethis.quieting = this.jessibuca.isMute()})},play(videoUrl) {if (videoUrl) {this.jessibuca.play(videoUrl)} else {// this.$message.error('播放地址出错')this.destroy()}},mute() {this.jessibuca.mute()},cancelMute() {this.jessibuca.cancelMute()},pause() {this.jessibuca.pause()this.playing = falsethis.err = ''this.performance = ''},destroy() {if (this.jessibuca) {this.jessibuca.destroy()}this.create()this.playing = falsethis.loaded = falsethis.performance = ''}}
}
</script>
<style>
#container {background: rgba(13, 14, 27, 0.7);width: 100%;height: 100%;
}
</style>

3、使用组件

  1. 引入
import VideoPlayer from '@/components/VideoPlayer.vue'
  1. 使用
<VideoPlayer ref="VideoPlayer"></VideoPlayer>
  1. 播放
let url = 'http://182.150.58.94:15280/rtp/44010200492000000001_34020000001320000110.flv'
this.$refs.VideoPlayer.play(url)

效果

在这里插入图片描述

参考文档:

jessibuca-api-文档
参考官方实例 jessibuca-vue-demo

http://www.lryc.cn/news/96640.html

相关文章:

  • iptables安全技术和防火墙
  • 微信小程序开发5
  • 【算法题】2681. 英雄的力量
  • fastutil简单测试下性能
  • 【FAQ】关于无法判断和区分用户与地图交互手势类型的解决办法
  • 腾讯云裸金属服务器CPU型号处理器主频说明
  • 工程安全监测无线振弦采集仪在建筑物中的应用
  • 【iOS】isKindOfClass和isMemberOfClass方法
  • 李飞飞「具身智能」VoxPoser:0预训练完成复杂指令
  • 前端八股文
  • 前端年度工作述职报告优秀
  • 【MyBatis 学习一】认识MyBatis 第一个MyBatis查询
  • TCP 和 UDP
  • springboot配置自定义数据源(Druid德鲁伊)的步骤。
  • K8S:容器日志收集与管理
  • Flutter系列文章-Flutter进阶
  • 【C++】C++11右值引用|新增默认成员函数|可变参数模版|lambda表达式
  • rust学习-线程
  • 题目:2180.统计各位数字之和为偶数的整数个数
  • 3dsmax制作一个机器人
  • C++的类型转换运算符:reinterpret_cast
  • flask中的cookies介绍
  • adnroid 11. 0 Activity启动流程图解
  • 了解Unity编辑器之组件篇Physics(四)
  • “数字中华 点亮未来”中华线上客户节 盛大开幕
  • 中文分词入门:使用IK分词器进行文本分词(附Java代码示例)
  • CTFSHOW web 信息收集
  • 速锐得开发社区-新一代汽车网络通信技术CAN FD的特点归纳
  • Android adb shell 查看App内存(java堆内存/vss虚拟内存/详细的内存状况/内存快照hprof)和系统可用内存
  • java篇 类的进阶0x0A:万类之祖:Object 类