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

<head>
  <title>𝙲ʀɪᴄ 𝙲ᴇɴᴛʀᴀʟ</title>
  <link rel="icon" href="https://upload.wikimedia.org/wikipedia/commons/thumb/8/82/Telegram_logo.svg/2048px-Telegram_logo.svg.png" type="image/png" sizes="250x250">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/shaka-player/4.12.5/shaka-player.ui.min.js" crossorigin="anonymous"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/shaka-player/4.12.5/controls.min.css" crossorigin="anonymous">
  <style>
    body {
      margin: 0;
      background-color: black;
    }

    /* Shaka Player container */
    [data-shaka-player-container] {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    /* Watermark styling */
    .watermark {
      position: absolute;
      top: 2px;
      left: 10px;
      width: 100px;
      opacity: 0.7;
      z-index: 999;
    }

    /* Custom styles for Shaka UI */
    .shaka-overflow-menu {
      background-color: rgb(41, 41, 163);
      color: rgb(153, 153, 153);
    }

    .shaka-overflow-menu button:hover {
      background-color: rgb(45, 45, 45);
    }

    .shaka-settings-menu {
      background-color: rgb(35, 35, 35);
      color: rgb(255, 255, 255);
    }

    .shaka-settings-menu button {
      color: rgb(255, 255, 255);
    }

    .shaka-settings-menu button:hover {
      background-color: rgb(45, 45, 45);
    }
  </style>
</head>

<body>
  <div data-shaka-player-container>
    <video autoplay muted data-shaka-player id="video" poster="https://upload.wikimedia.org/wikipedia/commons/f/fc/Astro_Cricket_%282024%29.png" style="width:100%;height:100%"></video>
    <img src="https://i.postimg.cc/WzwG90R8/Picsart-25-01-17-13-51-59-577.png" alt="Watermark" class="watermark">
  </div>

  <script>
    // Telegram Channel Confirmation
    if (confirm("𝖩𝗈𝗂𝗇 𝖮𝗎𝗋 𝖳𝖾𝗅𝖾𝗀𝗋𝖺𝗆 𝖢𝗁𝖺𝗇𝗇𝖾𝗅 @𝙲ʀɪᴄ𝙲ᴇɴᴛʀᴀʟ")) {
      window.location.href = "https://t.me/+-rDNhsdrZr1mNmU9";
    }

    // Initialize Shaka Player
    async function init() {
      const videoElement = document.getElementById("video");
      const ui = videoElement.ui;
      const controls = ui.getControls();
      const player = controls.getPlayer();

      // Expose player and UI globally for debugging
      window.player = player;
      window.ui = ui;

      // Add JWT Authorization header
      player.getNetworkingEngine().registerRequestFilter((type, request) => {
        if (type === shaka.net.NetworkingEngine.RequestType.SEGMENT) {
          request.headers['Authorization'] = 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ3bXZlciI6Miwid21pZGZtdCI6ImFzY2lpIiwid21pZHR5cCI6MSwid21rZXl2ZXIiOjEsIndtaWRsZW4iOjUxMiwid21pZCI6IllXTm1aVGN3TmpndE1UVmlNeTAwT1RGbUxUazRNREF0TTJRNU16RTBZV0kyWmpFNSIsIndtb3BpZCI6MzIsImV4cCI6MTczNzI3MjY3OSwiaWF0IjoxNzM2NjY4Njc5fQ.QBrJxYs6bQu0zzWMBJCTL1ISKPmNUJ4lfqDszzbPf5Q';
        }
      });

      // Configure player settings
      player.configure({
        drm: {
          clearKeys: {
            'a8eb0f152c6e429ca7a53f399aadf257': 'c593c2eeea62742285b99e4d87b1c84a'
          }
        }
      });

      // Error handling
      player.addEventListener('error', onPlayerError);
      controls.addEventListener('error', onUIError);

      try {
        // Load the video
        await player.load('https://d1yws6emo43ny.cloudfront.net/CH5/masterCH5.mpd');
        console.log('The video has now been loaded!');
      } catch (error) {
        onPlayerError(error);
      }
    }

    function onPlayerError(error) {
      console.error('Player error:', error);
    }

    function onUIError(event) {
      console.error('UI error:', event.detail);
    }

    // Fallback for Shaka Player UI load failure
    function initFailed() {
      console.error('Unable to load the UI library!');
    }

    // Initialize the player on DOM load
    document.addEventListener('shaka-ui-loaded', init);
    document.addEventListener('shaka-ui-load-failed', initFailed);
  </script>
</body>

</html>