1.安装
npm install hls.js
2.使用
<video ref="hlsvideo" loop autoplay controls></video>
import Hls from 'hls.js';
private init(data) {
// 支持 .m3u8 hls
const hlsvideo = this.$refs.hlsvideo as HTMLMediaElement;
const hls = new Hls();
hls.loadSource(data.videoUrl);
hls.attachMedia(hlsvideo);
hls.on(Hls.Events.MANIFEST_PARSED, () => {
hlsvideo.play();
});
}
网友评论