vue中使用flv.js播放视频
<template>
<div>
<video controls autoplay muted width="100%" height="500" id="videoElement"></video>
</div>
</template>
<script>
import flvjs from 'flv.js'
export default {
name: 'App',
components: {
},
mounted() {
this.$nextTick(() => {
this.createVideo()
})
},
methods: {
createVideo() {
if (flvjs.isSupported()) {
var videoElement = document.getElementById('videoElement');
var flvPlayer = flvjs.createPlayer({
type: 'flv',
url: 'http://platform.firerobot-online.com:7001/live/RXZ-MC52-L1A01-0016.flv' //你的url地址
});
flvPlayer.attachMediaElement(videoElement);
flvPlayer.load();
flvPlayer.play();
}
}
}
}
</script>