<?php
    session_start();
    $main_video = isset($_SESSION['main_video']) ? $_SESSION['main_video'] : '';
   
    $Video = [
        "Eroge-de-Subete-wa-Kaiketsu-Dekiru-1.mp4","Ima made de Ichiban Yokatta Sex - Episode 1.mp4",
"ima-made-de-ichiban-yokatta-sex-the-animation-episode-2_(1).mp4","ima-made-de-ichiban-yokatta-sex-the-animation.mp4",
"Kaede to Suzu The Animation - Episode 2.mp4","Kaede to Suzu The Animation -Episode 1-720p.mp4",
"knight-of-erin-ep-1-720p.mp4","knight-of-erin-ep-2-720p.mp4",
"knight-of-erin-ep-3-720p.mp4","knight-of-erin-ep-4-720p.mp4",
"Overflow - 01 720p.mp4",
"Overflow Episode 03 English Subbed [1080p].mp4",
"Overflow Episode 2 720p-WEBRip [Eng Subbed].mp4",
"Overflow Episode 4.mp4",
"Princess Lover[HH]direct_PID1726[HD].mp4",
"Princess Lover[HH]direct_PID1728[HD].mp4",
"Shakuen no Eris - Episode 1.mp4",
"Shakuen no Eris - Episode 2.mp4",
"Shakuen no Eris - Episode 3.mp4",
"Shakuen no Eris - Episode 4.mp4",
"Toilet no Hanako-san vs Kukkyou Taimashi - Episode 1.mp4",
"Toshi Densetsu Series - Episode 1.mp4",
"[NekoPoi] Elf ni Inmon o Tsukeru Hon The Animation - 01 [720P].mp4",
"[NekoPoi]_Mayohiga_no_Oneesan_-_01_[uncen]_[720P]_[nekopoi.care].mp4"
    ];
    $C = rand(0,count($Video));
$Test = [
    "Ayase Eli 13813323-480p.mp4",
    "Ayase Eli.mp4",
    "Kunikida Hanamaru.mp4",
    "Kunikida Hanamaru2.mp4",
    "Matsuura Kanan +Ohara mari.mp4",
    "Nishiko Maki.mp4",
    "Nishiko Maki2.mp4",
    "Nishoko Maki3.mp4",
    "Sakurauchi Riko.mp4",
    "Sakurauchi Riko2.mp4",
    "Takami Chika.mp4",
    "Toujo Nozomi.mp4",
    "Tsuhima Yoshiko2.mp4",
    "Tsuhima Yoshiko3.mp4",
    "Tsushima Yoshiko.mp4",
    "Watanabe You 3.mp4",
    "Watanabe You.mp4",
    "Watanabe You2.mp4"

];


    $A = "D:/G424/1. N Abdillah Ramadlan/Proposal 14461003/REAP/Read/Album/Try/5. Formalhault/T18/Series";
    $Video1 = $A."/".$Video[$C];
    $Video2 = "D:/G424/1. N Abdillah Ramadlan/Proposal 14461003/REAP/Read/Album/Try/5. Formalhault/T18/Lovelive/".$Test[rand(0,count($Test))];
    $Video3 = "D:/G424/1. N Abdillah Ramadlan/Proposal 14461003/REAP/Read/Album/Try/5. Formalhault/T18/Lovelive/Watanabe You2.mp4";


?>

<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Penampil Video</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            text-align: center;
            display: flex;
            flex-direction: row;
            justify-content: center;
            align-items: flex-start;
            background-color: black;
            color: white;
        }
        .video-container {
            width: 60%;
        }
        .info{
            align-items: right;
            text-align: left;
        }
        video{
            width: 100%;
        }
        .recommendations {
            width: 30%;
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        .recommendation-item {
            width: 60%;
            margin-bottom: 20px;
            text-align: left;
        }
    </style>
</head>
<body>
    <div class="recommendations">
        <h2><a href="http://localhost/Oort%20V0.1/Body.php">Rekomendasi Video</h2></a>
        <script>
            function updateMainVideo(videoPath) {
                fetch('update_video.php', {
                method: 'POST',
                headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
                },
                 body: 'main_video=' + encodeURIComponent(videoPath)
                }).then(response => response.text())
            .then(result => {
            // Reload halaman untuk melihat perubahan
            location.reload();
                });
            }
        </script>

        <div class="recommendation-item">
            <a  href="#" onclick="updateMainVideo('<?php echo $Video1; ?>'); return false;">
                <video width="300">
                    <source src="data:video/mp4;base64,<?= base64_encode(file_get_contents($Video1)) ?>" type="video/mp4">
                    Your browser does not support the video tag.
                    </a>
                </video>
        </div>
        <div class="recommendation-item">
            <a href="#" onclick="updateMainVideo('<?php echo $Video2; ?>'); return false;">
                <video width="300" >
                    <source src="data:video/mp4;base64,<?= base64_encode(file_get_contents($Video2)) ?>" type="video/mp4">
                    Your browser does not support the video tag.
                    </a>
                </video>
        </div>
        <div class="recommendation-item">
            <a href="#" onclick="updateMainVideo('<?php echo $Video3; ?>'); return false;" >
                <video width="300" >
                    <source src="data:video/mp4;base64,<?= base64_encode(file_get_contents($Video3)) ?>" type="video/mp4">
                    Your browser does not support the video tag.
                </video>
            </a>
        </div>

    </div>
    <div class="video-container">
        <h1>Penampil Video</h1>
        <video controls width="300" id="mainVideoPlayer" height: 400px;>
            <source id="mainSource" src="data:video/mp4;base64,<?= base64_encode(file_get_contents($main_video)) ?>" type="video/mp4">
                Your browser does not support the video tag.
        </video>
        <div class="info">
            <P>bbbb</P>
        </div>
        <P>aaaaa</P>
    </div>

</body>
</html>