安装
npm i flv.js
html
<div class="video"><videov-if="videoId"controls id="videoElement"preload="metadata"><source :type="`video/${allData.videoType}`" />您的浏览器不支持HTML5视频播放。</video>
</div>
js
<script>
import flvjs from 'flv.js';
export default {components: {},data() {return {flvPlayer:null,videoSrc:require('../assets/img/“二七”大罢工.mp4'),videoType:''}},mounted() {this.setupPlayer();},methods: {setupPlayer() {const videoElement = document.getElementById('videoElement');if (this.videoType === 'flv' && flvjs.isSupported()) {console.log(123456);// 使用 flv.js 播放 FLV 视频this.flvPlayer = flvjs.createPlayer({type: 'flv',url:this.videoSrc,});this.flvPlayer.attachMediaElement(videoElement);this.flvPlayer.load();// this.flvPlayer.play()} else {videoElement.src = this.videoSrc;videoElement.load();// videoElement.play();}},},
}
</script>