安装 flv 插件
"flv.js": "^1.5.0",
在使用页面引入
import flv from 'flv.js'
使用
<template>
<div>
<video
id="video"
ref="videoElement"
name="videoElement"
controls
autoplay="autoplay"
muted
:style="{
width: '100%',
height: '100%'
}"
>
</video>
</div>
</template>
// 使用
url = 视频地址
id = 页面元素 box id
this.createVideo(url,id);
// 创建视频方法
createVideo(url,refs) {
const player = flv.createPlayer({
url,
type: 'flv',
enableWorker: true, // 浏览器端开启flv.js的worker,多进程运行flv.js
isLive: false, // 直播模式
hasAudio: false, // 关闭音频
hasVideo: true,
stashInitialSize: 128,
enableStashBuffer: true // 播放flv时,设置是否启用播放缓存,只在直播起作用。
})
player.attachMediaElement(this.$refs[refs])
player.load()
player.play()
}