JS播放m3u8

wgscd發表於2024-09-02

JS播放m3u8:

利用 hls.min.js

<!DOCTYPE html>
<html>
<head>
    <title>HLS Video Playback</title>
</head>
<body>
    <video id="video" controls></video>
 
    <script src="https://cdn.jsdelivr.net/hls.js/latest/hls.min.js"></script>
    <script>
        var video = document.getElementById('video');
        var hls = new Hls();
 
        hls.loadSource('https://yourdomain.com/path/to/your/video.m3u8');
        hls.attachMedia(video);
        hls.on(Hls.Events.MANIFEST_PARSED, function() {
            video.play();
        });
    </script>
</body>
</html>

  

相關文章