Video Gallery

{source}

 

 

<?php

 

// Call set_include_path() as needed to point to your client library.

Header(‘Content-Type: text/html; charset=UTF-8’);

$ch = curl_init();

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

if(!isset($_SESSION[‘currentPageNo’]))

{

    $_SESSION[‘currentPageNo’] = 1;

}

 

 

 

if ($_SERVER[‘REQUEST_METHOD’] === ‘POST’) {

 

 

    if (isset($_POST[‘btnPrev’]) && isset($_SESSION[‘tokenPrevious’])) {

        curl_setopt($ch, CURLOPT_URL, ‘https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=28&playlistId=FLElXUsRMwhE4WUYvn3OkRAg&key=AIzaSyDXEYRrAn44SfZFZquW1rfAcQAzKTtfnpQ&pageToken=’.$_SESSION[‘tokenPrevious’]);

        

    }

    else if (isset($_POST[‘btnNext’]) && isset($_SESSION[‘tokenNext’])) {

        curl_setopt($ch, CURLOPT_URL, ‘https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=28&playlistId=FLElXUsRMwhE4WUYvn3OkRAg&key=AIzaSyDXEYRrAn44SfZFZquW1rfAcQAzKTtfnpQ&pageToken=’.$_SESSION[‘tokenNext’]);

        

    }

    else

    {

        curl_setopt($ch, CURLOPT_URL, ‘https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=28&playlistId=FLElXUsRMwhE4WUYvn3OkRAg&key=AIzaSyDXEYRrAn44SfZFZquW1rfAcQAzKTtfnpQ’);

        $_SESSION[‘currentPageNo’] = 1;

    }

             

}

else

{

    curl_setopt($ch, CURLOPT_URL, ‘https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=28&playlistId=FLElXUsRMwhE4WUYvn3OkRAg&key=AIzaSyDXEYRrAn44SfZFZquW1rfAcQAzKTtfnpQ’);

    $_SESSION[‘currentPageNo’] = 1;

}

 

 

/*if(isset($_SESSION[‘token’]))

{

    if($_SESSION[‘token’] === “”)

    {

        curl_setopt($ch, CURLOPT_URL, ‘https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=30&playlistId=FLElXUsRMwhE4WUYvn3OkRAg&key=AIzaSyDXEYRrAn44SfZFZquW1rfAcQAzKTtfnpQ’);

    }

    else

    {

        curl_setopt($ch, CURLOPT_URL, ‘https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=30&playlistId=FLElXUsRMwhE4WUYvn3OkRAg&key=AIzaSyDXEYRrAn44SfZFZquW1rfAcQAzKTtfnpQ&pageToken=’.$_SESSION[‘token’]);

    }

}

else

{

    curl_setopt($ch, CURLOPT_URL, ‘https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=30&playlistId=FLElXUsRMwhE4WUYvn3OkRAg&key=AIzaSyDXEYRrAn44SfZFZquW1rfAcQAzKTtfnpQ’);

}*/

$result = curl_exec($ch);

curl_close($ch);

 

$obj = json_decode($result,true);

 

 

if (isset($_POST[‘btnPrev’]) && isset($_SESSION[‘tokenPrevious’])) 

{

    if($_SESSION[‘currentPageNo’] > 0)

        {$_SESSION[‘currentPageNo’] = $_SESSION[‘currentPageNo’] – 1;}

}

else if (isset($_POST[‘btnNext’]) && isset($_SESSION[‘tokenNext’])) 

{

    if($_SESSION[‘currentPageNo’] < (ceil($obj[‘pageInfo’][‘totalResults’]/28)))

        {$_SESSION[‘currentPageNo’] = $_SESSION[‘currentPageNo’] +1;}

}

    

if(isset($obj[‘prevPageToken’]))

{

    $linkPrevious = “http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]”;

    $_SESSION[‘tokenPrevious’] = $obj[‘prevPageToken’];

}

if(isset($obj[‘nextPageToken’]))

{

    $linkNext = “http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]”;

    $_SESSION[‘tokenNext’] = $obj[‘nextPageToken’];

    

}

//echo $result;

//echo $_GET[‘token’]; 

$i=0;

print ‘<div class=”wrap”>’;

 

foreach($obj[‘items’] as $item) {

$i++;

if($i==0 || $i%4==0)

    {

        //print ‘<div id=”idRow”>’;

    }

    //print ‘<div class=”classBox”>’;

    print ‘<div class=”box”>’;

    print ‘<div class=”boxInner”>’;

    print ‘<a class=”popup” href=”#!” data-link=”http://www.youtube.com/embed/’.$item[‘snippet’][‘resourceId’][‘videoId’].’?enablejsapi=1″><img src=”‘. $item[‘snippet’][‘thumbnails’][‘medium’][‘url’] . ‘” border=”0″ alt=”” /></a>’;

    //print ‘<p itemprop=”name”>’ . $item[‘snippet’][‘title’] .'</p>’;

    print ‘<div class=”titleBox”>’.$item[‘snippet’][‘title’].'</div>’;

    print ‘</div>’;

    print ‘</div>’;

    if($i==0 || $i%4==0)

    {

        //print ‘</div>’;

    }

 

}

print ‘</div>’;

$htmlBody = ”;

?>

 

<!doctype html>

<html>

  <head>

    <title>Video list</title>

      <meta name=”viewport” content=”width=device-width, initial-scale=1.0″ />

      <style type=”text/css”>

nav#t3-mainnav {

    margin: 0px !important;

    overflow: visible;

}

div#idRow{

    /*float:left;          */

}

.classBox{

    /*float:left;*/

    /*padding:10px;

    width: 250px;*/

}

img {

   /* width: 100%;

    height: auto;*/

}

          

          body {

   margin: 0;

   padding: 0;

   background: #EEE;

   /*font: 10px/13px ‘Lucida Sans’,sans-serif;*/

}

.wrap {

   overflow: hidden;

   margin: 10px;

}

.box {

    float: left;

    position: relative;

    width: 25%;

    padding-bottom: 19%;

    margin-bottom: 4px;

}

.boxInner {

   position: absolute;

   left: 10px;

   right: 10px;

   /*top: 10px;

   bottom: 10px;

   overflow: hidden;*/

}

.boxInner img {

   width: 100%;

}

.boxInner .titleBox {

    position: absolute;

    bottom: 0;

    left: 0;

    right: 0;

    margin-bottom: -36px;

    background: #000;

    background: rgba(0, 0, 0, 0.5);

    color: #FFF;

    padding: 3px;

    text-align: center;

    -webkit-transition: all 0.3s ease-out;

    -moz-transition: all 0.3s ease-out;

    -o-transition: all 0.3s ease-out;

    transition: all 0.3s ease-out;

    height: 34px;

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;

}

body.no-touch .boxInner:hover .titleBox, body.touch .boxInner.touchFocus .titleBox {

   margin-bottom: 0;

}

@media only screen and (max-width : 480px) {

   /* Smartphone view: 1 tile */

   .box {

      width: 100%;

      padding-bottom: 100%;

   }

}

@media only screen and (max-width : 650px) and (min-width : 481px) {

   /* Tablet view: 2 tiles */

   .box {

      width: 50%;

      padding-bottom: 50%;

   }

}

@media only screen and (max-width : 1050px) and (min-width : 651px) {

   /* Small desktop / ipad view: 3 tiles */

   .box {

      width: 33.3%;

      padding-bottom: 33.3%;

   }

}

@media only screen and (max-width : 1290px) and (min-width : 1051px) {

   /* Medium desktop: 4 tiles */

   .box {

      width: 25%;

      padding-bottom: 25%;

   }

}

    #video-view {

position:fixed;

   top: 10vw;

    left: 25vw;

    width: 49.25vw;

    height: 35.4vw;

    /*margin-top: 9vw; /*set to a negative number 1/2 of your height

    margin-left: 15vw; /*set to a negative number 1/2 of your width*/

    border: 1px solid #ccc;

    background-color: #f3f3f3;

        display: none;

        z-index:2000;

        align-items: center;

}      

    #idcover 

    {

        height:100%;

        width:100%;

        position:fixed;

        left:0;

        top:0;

        z-index:1 !important;

        background-color:black;

        filter: alpha(opacity=75); /* internet explorer */

        -khtml-opacity: 0.75;      /* khtml, old safari */

        -moz-opacity: 0.75;      /* mozilla, netscape */

        opacity: 0.75;      /* fx, safari, opera */

        display: none;

 

    }

.pagination a {

    background: none repeat scroll 0 0 #007ab7;

    color: #fff;

    font-size: 14px;

    margin: 0 5px;

    padding: 2px 5px;

}

</style>

      <script src=”https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js”></script>

      <script>

      $(“.popup”).click(function () {

    var $this = $(this);

    var $iframe = $(“<iframe>”).attr(“src”, $this.data(“link”)).css({“width”: “49vw”, “height”: “34vw”});

    var $title = $(“<a class=’idclose’ href=’#!’ >”).text(“Close”);

    $(“#video-view”).css(“display”,”block”);

    $(“#idcover”).css(“display”,”block”);

          //$(“#video-view”).fadeIn(500);

          //$(“#idcover”).fadeTo(500, 0.5);

    $(“#video-view”).html($title).append($iframe);

    //$iframe.wrap(“<div class=’class-video’>”);

})

      $(document).on(‘ click’, ‘.idclose’, function(){

         $(“#idcover”).css(“display”,”none”);

          $(“#video-view”).css(“display”,”none”);

          })

      </script>

      

  </head>

  <body>

    <form action=”<?php echo $_SERVER[‘PHP_SELF’]; ?>” method=”post”> 

    <?php= $htmlBody ?>

      <div id=”idcover”></div>

      <div id=”video-view”></div>

      <span class=”pagination”>

          <input type=”submit” name=”btnPrev” value=”Prev”>

          <span><?php echo $_SESSION[‘currentPageNo’] ?></span>

          <span> / </span>

          <span><?php echo ceil($obj[‘pageInfo’][‘totalResults’]/28)?></span>

          <input type=”submit” name=”btnNext” value=”Next”>

      </span>

      </form>

  </body>

</html>

 

{/source}

Leave a Reply