<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>NOTFLIX TV</title>
    <script src="//content.jwplatform.com/libraries/SAHhwvZq.js"></script>
    <style>
        body {
            margin: 0;
            font-family: Arial, sans-serif;
            background-color: #333;
            color: #fff;
            height: 100vh;
            display: flex;
            flex-direction: column;
        }
        
        #jwplayerDiv {
            width: 100%;
            height: 60vh;
        }
        
        .playlist {
            background-color: #444;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            text-align: center;
            flex: 1;
            overflow-y: auto;
        }
        
        .playlist ul {
            list-style: none;
            padding: 0;
            margin: 0;
        }
        
        .playlist li {
            margin-bottom: 10px;
        }
        
        .playlist a {
            color: #fff;
            text-decoration: none;
        }
        
        .playlist a:hover {
            color: #ffcc00;
        }
        
        .playing {
            background-color: #4caf50;
            color: #fff;
            padding: 5px;
            border-radius: 5px;
        }
        
        /* Mobile-friendly styles */
        @media only screen and (max-width: 768px) {
            #jwplayerDiv {
                height: 40vh;
            }
            .playlist {
                padding: 10px;
            }
        }
    </style>
</head>
<body>
    <div id="jwplayerDiv"></div>
    <div class="playlist">
        <ul id="playlistList"></ul>
    </div>
    
<iframe 
  src="chatbox.php" 
  frameborder="0" 
  width="100%" 
  height="500" 
  scrolling="no">
</iframe>
    <script>
        document.addEventListener('contextmenu', function(event) {
            event.preventDefault();
        });
        
        fetch('channels.php')
            .then(response => response.json())
            .then(data => {
                const playlistList = document.getElementById('playlistList');
                
                data.forEach((channel, index) => {
                    const listItem = document.createElement('LI');
                    const link = document.createElement('A');
                    link.href = '#';
                    link.textContent = channel.name;
                    link.onclick = () => playStream(channel, link);
                    listItem.appendChild(link);
                    playlistList.appendChild(listItem);
                });
                
                playStream(data[0], document.querySelectorAll('.playlist a')[0]);
            });
        
        function playStream(channel, element) {
            const playerSetup = {
                file: channel.file,
                autostart: true,
                stretching: "",
                width: "100%",
                height: "100%",
                type: channel.type,
                drm: channel.drm
            };
            
            jwplayer("jwplayerDiv").setup(playerSetup);
            
            document.querySelectorAll('.playlist a').forEach(a => a.classList.remove('playing'));
            element.classList.add('playing');
        }
    </script>
</body>
</html>