现在的代码只能实现点击页面就自动加载视频,但是考虑到有多个视频,一起加载会出现卡顿的现象,并且自动加载对用户的体验也不好,有了解hls.js的朋友吗?
var video = document.getElementById('video');
if(Hls.isSupported()) {
var hls = new Hls();
hls.loadSource("http://1252093142.vod2.myqcloud.com/8100044199.m3u8");
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED,function() {
try {
video.play();
} catch (error) {
console.log(error);
}
});
}