<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>演示:HTML5播放m3u8(hls)格式视频</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/demo.css">
<style>
</style>
</head>
<body>
<div class="container">
<div>
<video id="video" controls loop="false" width="100%"></video>
</div>
<button id = "btn">播放位置</button>
</div>
<script src="js/hls.js"></script>
<script src="js/jquery-1.6.2.min.js"></script>
<script>
var video = document.getElementById('video');
if(Hls.isSupported()) {
var hls = new Hls();
hls.loadSource('http://127.0.0.1:8765/hls/test.m3u8');
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED,function() {
video.play();
});
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
video.src = 'http://127.0.0.1:8765/hls/test.m3u8';
video.addEventListener('loadedmetadata',function() {
video.play();
});
}
$("#btn").click(function(){
//获取播放位置用于截图
alert(video.currentTime);
})
</script>
</body>
</html>