华为实时视频使用FLV播放RTSP流

import flvjs from 'flv.js';

安装flv

复制代码
<video style="width:100%;height:100%;" ref="videoHWRef" ></video>

  // src 华为rtsp流    rtsp://admin:[email protected]:554/xxx/trackID=1
  // url 需要后端提供视频源地址
  playVideo() {
	if (flvjs.isSupported() && src) {
	   let video = this.$refs['videoHWRef']
	   if (video) {
	     this.flvPlayer = flvjs.createPlayer(
	       {
	           type: "flv",
	           isLive: true,
	           hasAudio: false,
	           url: `${baseUrl}/iot/live/${window.btoa(src)}/live.flv`
	       },
	       {
	           autoCleanupSourceBuffer: true,
	           enableWorker: false, //不启用分离线程
	           enableStashBuffer: true, //关闭IO隐藏缓冲区
	           isLive: true,
	           lazyLoad: false,
	       }
	     );
	     this.flvPlayer.attachMediaElement(video);
	     try {
	       this.flvPlayer.load();
	       this.flvPlayer.play();  // 他还有很多的函数可以看一下flv.js的官方文档
	       // this.listenVideo(index);
	     } catch (error) {
	         console.log(error);
	     };
	   }
	 }
	}
  }

beforeDestroy() {
  if (this.flvPlayer) {
     this.flvPlayer.pause();
     this.flvPlayer.unload();
     this.flvPlayer.detachMediaElement();
     this.flvPlayer.destroy();
     this.flvPlayer = null;
   }
}

可播放

相关推荐
IoOozZzzz7 分钟前
Js扩展DOM、BOM、AJAX、事件、定时器
开发语言·javascript·ajax
inksci1 小时前
Vue 3 中通过 this. 调用 setup 暴露的函数
前端·javascript·vue.js
未来之窗软件服务2 小时前
monaco-editor 微软开源本地WEB-IDE-自定义自己的开发工具
开发语言·前端·javascript·编辑器·仙盟创梦ide
白白糖2 小时前
二、HTML
前端·html
子燕若水2 小时前
continue dev 的配置
java·服务器·前端
学习HCIA的小白2 小时前
关于浏览器对于HTML实体编码,urlencode,Unicode解析
前端·html
向明天乄3 小时前
Vue3 后台管理系统模板
前端·vue.js
香蕉可乐荷包蛋3 小时前
vue 常见ui库对比(element、ant、antV等)
javascript·vue.js·ui
彩旗工作室3 小时前
Web应用开发指南
前端
孙俊熙4 小时前
react中封装一个预览.doc和.docx文件的组件
前端·react.js·前端框架