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

声明:本站所有文章和图片,如无特殊说明,均为原创发布。商业转载请联系作者获得授权,非商业转载请注明出处。
随机推荐
WordPress 函数 add_option()、get_option() 和 update_option()
JWT 存储在 Cookie 和 Web Storage 的区别
WordPress 常用接口
什么是 XSS 攻击
Node.js child_process 模块
HTML 对话框元素 dialog
WordPress 调用自定义头像
WP_REST_Response 返回结果类