1.安装hls
npm i hls -dev
2.具体实现代码
<div class="test">
<video id="player" controls="" autoplay muted ></video>
</div>
</template>
<script>
export default{
data(){
return{
}
},
created(){
},
mounted(){
},
methods:{
playVideo(videoSrc){
if (Hls.isSupported()) {
var video = document.getElementById("player");
video.volume = 1.0;
var hls = new Hls();
var m3u8Url = decodeURIComponent(videoSrc);
hls.loadSource(m3u8Url);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED,()=>{
video.play();
});
}
}
}
}
</script>
<style>
video{
width:290px;
height:190px
}
</style>