Vue 中使用 flv.js 播放视频
1 详情信息flv.js git地址链接: https://github.com/bilibili/flv.js .引入依赖npm install --save flv.js代码<template><div><video autoplay controls width="100%" height="500" id="videoElement"></vide
·
-
1 详情信息
flv.js git地址链接: https://github.com/bilibili/flv.js .
-
引入依赖
npm install --save flv.js
-
代码
<template>
<div>
<video autoplay controls width="100%" height="500" id="videoElement"></video>
</div>
</template>
<script>
import flvjs from 'flv.js'
export default {
name: 'HelloWorld',
props: {
msg: String
},
mounted() {
this.$nextTick(() => {
this.createVideo()
})
},
methods: {
createVideo() {
if (flvjs.isSupported()) {
var videoElement = document.getElementById('videoElement');
var flvPlayer = flvjs.createPlayer({
type: 'flv',
url: 'url' //你的url地址
});
flvPlayer.attachMediaElement(videoElement);
flvPlayer.load();
flvPlayer.play();
}
}
}
}
</script>
更多推荐
已为社区贡献6条内容
所有评论(0)