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

修改时间 2019-03-27

真诚赞赏,手留余香
赞赏
随机推荐
Node.js 数据验证 Validator.js
Electron小试
文件上传进度
新媒体工作者的日常
AI 制作的图标上传到 iconfont 以后丢失描边的解决办法
php5.4环境下安装ECshop出现Strict Standards的解决方案
简单的webpack配置文件
Koa.js 中间件 koa-session
CentOS 8 安装 MySQL 5.7 或 MySQL 8
SQL表名,应该用复数还是单数