<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>@CRICSPORTCENTRAL</title>
  <link rel="shortcut icon" href="https://i.pinimg.com/originals/31/2a/f9/312af9235aadad69655688eaee97eabf.png" type="image/x-icon">
  <link rel="stylesheet" href="https://cdn.plyr.io/3.7.8/plyr.css" />
  <style>
    @import url("https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap");

    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
      font-family: "Roboto", system-ui, sans-serif;
    }

    #my-video {
      width: 100%;
      height: 100vh;
      height: 100svh;
    }

    video {
      width: 100% !important;
      height: 100vh;
      height: 100svh !important;
    }

    .watermark {
      position: absolute;
      top: 10px;
      left: 10px;
      z-index: 1000;
      opacity: 0.8;
    }

    .watermark img {
      width: 130px;
      height: auto;
    }
  </style>
</head>

<body>
  <div class="watermark">
    <img src="https://i.postimg.cc/L8dkBG8f/Picsart-24-12-24-15-43-58-207.png" alt="Watermark">
  </div>

  <video id="player" controls preload="auto" autoplay muted></video>

  <script src="https://cdn.jsdelivr.net/npm/hls.js@1.4.0/dist/hls.min.js"></script>
  <script src="https://cdn.plyr.io/3.7.8/plyr.js"></script>
  <script>
    document.addEventListener("DOMContentLoaded", () => {
      if (confirm("Join Our Telegram Channel @CRICSPORTCENTRAL")) {
        window.location.href = "https://t.me/CRICSPORTCENTRAL";
      }

      const video = document.getElementById("player");
      const source = "https://m118753.protect-cdn.net/live/m1-index.m3u8";
      const defaultOptions = {};

      if (Hls.isSupported()) {
        const hls = new Hls();
        hls.loadSource(source);

        // Attach media to video element
        hls.attachMedia(video);

        // Pre-buffer segments for smoother playback
        hls.config.maxBufferSize = 120 * 1000 * 1000; // 120MB
        hls.config.maxBufferLength = 30; // 30 seconds of buffer

        // On manifest parsed, initialize Plyr
        hls.on(Hls.Events.MANIFEST_PARSED, function () {
          const availableQualities = hls.levels.map((l) => l.height);
          availableQualities.unshift(0);

          defaultOptions.controls = [
            "play-large",
            "rewind",
            "play",
            "fast-forward",
            "progress",
            "current-time",
            "mute",
            "volume",
            "captions",
            "settings",
            "pip",
            "fullscreen",
            "airplay",
          ];

          defaultOptions.quality = {
            default: 0,
            options: availableQualities,
            forced: true,
            onChange: (quality) => {
              if (quality === 0) {
                hls.currentLevel = -1; // Auto
              } else {
                hls.levels.forEach((level, index) => {
                  if (level.height === quality) {
                    hls.currentLevel = index;
                  }
                });
              }
            },
          };

          new Plyr(video, defaultOptions);
        });
      } else if (video.canPlayType('application/vnd.apple.mpegurl')) {
        video.src = source;
      }
    });
  </script>
</body>

</html>