<?php
$cnn = $_GET['cnn'];
if(empty($cnn)){$cnn='9OyVV_3ePsY';}
//$yurl = 'https://www.youtube.com/@MashaBearEN/videos';
$yurl = 'https://www.youtube.com/c/MashaBearEN/videos';
//$yurl = 'https://www.youtube.com/channel/MashaBearEN/videos';

$ch = curl_init();
    curl_setopt($ch,CURLOPT_URL,$yurl);
   // curl_setopt($ch,CURLOPT_URL,"https://api.myip.com");
  	
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_HEADER, false);
  $buffer = curl_exec($ch);
  	curl_close($ch);
  print_r($buffer);
  exit;
  $product = explode('"watchEndpoint":{"videoId":"',$buffer);
  $productok = explode('"',$product[1]);
  
  //echo $productok[0].'='.$yurl;
  //  echo $productok[0];
$cnnok= $productok[0];
  //exit;





?>
<html>
    <body>
<style>
html, body {
  margin:0px;
  height:100%;
}

.box {
  background: black;
  height:100%;
  z-index: -1;
}
.overlay {
  position:absolute;
  top:0px;
  left:0px;
  background-color: rgba(0, 0, 0, 0);
  width: 100%;
  height: 100%;
  z-index: 2;

}
</style>
<div class="overlay" id="overlay"></div>
<div class="box" id="player"></div>
    <script type="text/javascript">


    // 3. This function creates an <iframe> (and YouTube player)
    //    after the API code downloads.
    var player;
    function onYouTubeIframeAPIReady() {
       var videoID = ['<?=$cnnok;?>'];
       player = new YT.Player('player', {
       height: '100%',
       width: '100%',
       videoId: videoID,
       events: {
          'onReady': onPlayerReady,
          'onStateChange': onPlayerStateChange
           }
        });

          function onPlayerReady(event) {
              event.target.playVideo();
          }

          function onPlayerStateChange(event) {
           var state = event.target.getPlayerState();
            if (state === 2) {
                alert("Paused");
            }
             else if (state === 0) {
                alert("Ended");
             }
            }
          }
    </script>

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">"></script>
    <script type="text/javascript" src="https://www.youtube.com/iframe_api"></script>


    </body>
    </html>
