Hls.js 播放 m3u8
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script src="hls.js"></script>
    <video id="video" controls="controls"></video>

    <script>
    var video = document.getElementById('video');
    if(Hls.isSupported()) {
        var hls = new Hls();
        hls.loadSource('http://localhost/video/video/playlist.m3u8');
        hls.attachMedia(video);
        hls.on(Hls.Events.MANIFEST_PARSED,function() {
            video.play();
        });
    }
    else if (video.canPlayType('application/vnd.apple.mpegurl')) {
        video.src = 'http://localhost/video/video/playlist.m3u8';
        video.addEventListener('loadedmetadata',function() {
        video.play();
        });
    }
    </script>
</body>
</html>

 

演示:http://cloud.restfulapi.cn/m3u8/index.html

声明:本站所有文章和图片,如无特殊说明,均为原创发布。商业转载请联系作者获得授权,非商业转载请注明出处。
随机推荐
JavaScript document 对象
JavaScript DOM 文档对象模型
Node.js 控制台进度条实现原理
版权相关
选择排序
CSS 媒体特性 prefers-color-scheme
Node.js 数据库模块 mysql2
JavaScript screen对象