vue 中支持m3u8格式
https://blog.csdn.net/qq_36410795/article/details/107109514
第一步:npm install --save video.js npm install --save videojs-contrib-hls
第二部:import 'video.js/dist/video-js.css; import videojs from "video.js"; import "videojs-contrib-hls";
第三部:
<video
id="my-video"
class="video-js vjs-default-skin"
controls
preload="auto"
width="500px"
>
<source src="http://ivi.bupt.edu.cn/hls/cctv1hd.m3u8" type="application/x-mpegURL" />
</video>
第四部:
getVideo() {
videojs(
"my-video",
{
bigPlayButton: false,
textTrackDisplay: false,
posterImage: true,
errorDisplay: false,
controlBar: true
},
function() {
this.play();
}
);
}
第五步:
let _that = this; setTimeout(() => { _that.getVideo(); }, 300); 解决报错 找不到 ID