<!--
Copyright (C) 2023 Stefy Lanza <stefy@nexlab.net> and SexHack.me

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Video Stream</title>
    <style>
        body, html {
            margin: 0;
            padding: 0;
            height: 100%;
            overflow: hidden;
        }
        #videoContainer {
            width: 100%;
            height: 100%;
        }
        video {
            width: 100% !important;
            height: 100% !important;
            object-fit: contain;
        }
    </style>
</head>
<body>
    <div id="videoContainer">
        <video id="videoPlayer" autoplay muted playsinline>
            <source type="video/mp4">
            Your browser does not support the video tag.
        </video>
    </div>
    <script src="https://vjs.zencdn.net/7.20.3/video.min.js"></script>
    <script>
   	window.onload = function() {
      	var player = videojs('videoPlayer', {
              html5: {
                  vhs: {
                   overrideNative: !videojs.browser.IS_SAFARI
                  },
              nativeAudioTracks: false,
              nativeVideoTracks: false,
              autoplay: true,
				  muted: true,
				  controls: false,
              fluid: true,
              respomsive: true
              }});
      	player.src({ src: '{{ stream_url }}', type: 'application/x-mpegURL'});
      	player.play();
   	};

        // Function to handle resize
        function handleResize() {
            var videoContainer = document.getElementById('videoContainer');
            var video = document.getElementById('videoPlayer');
            video.style.width = videoContainer.clientWidth + 'px';
            video.style.height = videoContainer.clientHeight + 'px';
        }

        // Call handleResize initially and on window resize
        handleResize();
        window.addEventListener('resize', handleResize);

        // Listen for messages from the parent window
        window.addEventListener('message', function(event) {
            if (event.data === 'resize') {
                handleResize();
            }
        }, false);
    </script>
</body>
</html>
