<?php
include(__DIR__ . '/../includes/functions.php');
$mes = $db->select('bdtube', '*', 'id = :id', '', [':id' => 1]);
$link = $mes[0]['link'] ?? 'https://www.youtube.com/watch?v=o4qjk8_5gmU';


function getYouTubeVideoId($url) {
    $videoId = '';
    if (preg_match('/(youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/', $url, $matches)) {
        $videoId = $matches[2];
    }
    return $videoId;
}

$videoId = getYouTubeVideoId($link); 
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>YouTube AutoPlay Mute Loop No Controls No Branding Fullscreen</title>
    <style>
        body, html {
            margin: 0;
            padding: 0;
            height: 100%;
            overflow: hidden;
        }
        .video-container {
            width: 100%;
            height: 100%;
        }
        .video-container iframe {
            width: 100%;
            height: 100%;
        }
    </style>
</head>
<body>
    <div class="video-container">
        <iframe 
            src="https://www.youtube.com/embed/<?php echo $videoId; ?>?autoplay=1&mute=1&loop=1&playlist=<?php echo $videoId; ?>&controls=0&showinfo=0&modestbranding=1" 
            frameborder="0" 
            allow="autoplay; encrypted-media" 
            allowfullscreen>
        </iframe>
    </div>
</body>
</html>