vue jessibuca视频监控

一 :在官网下载最新的js 文件

decoder.js 、 decoder.wasm 、 jessibuca.js

Jessibuca官网

 二 :将三个文件放到public下跟index.html同级。

       以下是组件页面:

html:
   我这里是放在循环中
 <div :id="'tc-player' + n" :ref="'container' + n" class="player" style="width: 100%;     
  height: 100%"></div>
methods:{
    create(id) {
          let that = this
           let flag = false
           this.jessibuca = null
           var showOperateBtns = true // 是否显示按钮
           var $container = document.getElementById('tc-player' + id)
           this.jessibuca = new window.Jessibuca({
           container: $container, // 播放器容器
           videoBuffer: Number(0.2), // 缓存时长
           isResize: false,
           useWCS: true, // 是否开启Webcodecs硬解码
           loadingText: '加载中...',
           hasAudio: false,
           debug: false,
           supportDblclickFullscreen: showOperateBtns, // 是否支持屏幕的双击事件
           showBandwidth: showOperateBtns, // 显示网速    
                operateBtns: { // 配置操作按钮
                    fullscreen: true, // 是否显示全屏按钮
                    screenshot: true, // 是否显示截图按钮
                    play: true, // 是否显示播放暂停按钮
                    audio: true // 是否显示声音按钮

                },
            forceNoOffscreen: true, // 是否不使用离屏模式(提升渲染能力)
                isNotMute: false, // 是否开启声音,默认是关闭声音播放的
                timeout: 10 // 设置超时时长, 单位秒
             })
            this.jessibuca.on('log', function(msg) {
                console.log(msg, '信息,包含错误信息')
            })

            this.jessibuca.on('record', function(msg) {
                console.log('on record:', msg)
            })

            this.jessibuca.on('pause', function(msg) {
                console.log(msg, '触发暂停事件')
            })
             this.jessibuca.on('fullscreen', function(msg) {
                console.log(msg, '是否全屏')
                that.fullscreen = msg
                let doc = document.querySelector('.jessibuca-controls-right')
                if (!flag && that.isFlag) {
                let cloud = `
                <div class="jessibuca-controls-item jessibuca-record" id="cloudShow"                                     
                      style="display: flex;">
                 <i class="jessibuca-icon jessibuca-icon-record"></i>
                 <span class="icon-title-tips"><span class="icon-title">云台</span</span>
                    </div>
                    `
                  doc.insertAdjacentHTML('afterbegin', cloud)
                }

                document.getElementById('cloudShow').addEventListener('click', function() {
                    that.cloudShow = !that.cloudShow
                })

                flag = true
                if (msg == false) {
                    document.querySelector('.jessibuca-record').remove()
                    flag = false
                }
            })
            console.log(this.jessibuca, '初始化完成')
                this.playList.push(this.jessibuca)

            },
         // 销毁
        destroys() {
            if (this.playList != false) {
                for (let i = 0; i < this.playList.length; i++) {
                    this.playList[i].destroy()
                }
            }
        },
}

然后在业务层:

 // 请求接口后遍历
 this.$refs.supPlayer.create(index + 1)
 this.$refs.supPlayer.jessibuca.play(Response.data.flv)

如果是APP(uni-app),以下是我个人做法

我是将三个文件放入自己业务层目录下:

mounted() {
	this.create(this.playUrl)
},
destroyed() {
	this.jessibuca.destroy()
},
create(url) {
    let that = this
	var $container = document.getElementById('container');
	this.jessibuca = new Jessibuca({
	container: $container,
	videoBuffer: 0.2, // 缓存时长
	isResize: false,
	loadingText: "加载中",
	debug: false,
	showBandwidth: true, // 显示网速
	operateBtns: {
		fullscreen: true,
			screenshot: false,
			play: true,
			audio: true,
	},
	forceNoOffscreen: false,
	useMSE: true,
	hasAudio: false
	});
	that.jessibuca.on('fullscreen', function(msg) {
	if (msg) {
		that.jessibuca.setRotate(90)
	} else {
		that.jessibuca.setRotate(0)
	}
	})
	that.jessibuca.play(url)
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值