<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>播放m3u8</title>
</head>
<body>
    <video id="videoPlayer" controls autoplay></video>

    <script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
    <script>
        // 获取链接中的?yu=参数值作为m3u8地址
        function getM3u8Url() {
            var urlParams = new URLSearchParams(window.location.search);
            var m3u8Url = urlParams.get('yu');
            return m3u8Url;
        }

        if (Hls.isSupported()) {
            var video = document.getElementById('videoPlayer');
            var hls = new Hls();
            var m3u8Url = getM3u8Url();

            if (m3u8Url) {
                hls.loadSource(m3u8Url);
                hls.attachMedia(video);
                hls.on(Hls.Events.MANIFEST_PARSED, function () {
                    video.play();
                });
            } else {
               alert('未提供m3u8地址参数');
            }
        }
    </script>
</body>
</html>