<template>
<div>
<video ref="video" controls autoplay muted></video>
</div>
</template>
<script>
import Hls from 'hls.js';
export default {
name: 'VideoPlayer',
mounted() {
const video = this.$refs.video;
if (Hls.isSupported()) {
const hls = new Hls();
hls.loadSource('https://8c809f0-hd.m3u8');//换成自己的链接
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, function() {
video.play();
});
}
//实时获取播放时间
video.addEventListener('timeupdate', () => {
console.log( video.currentTime,'111');
});
}
};
</script>