static function displayVideoList($playlist_results, $Video_List_ContentDetails_Statistics)
 {
     $playlist_count = count($playlist_results);
     echo '<div>';
     for ($index = 0; $index < $playlist_count; $index++) {
         $item = $playlist_results[$index];
         $video_id = $item->snippet->resourceId->videoId;
         //echo var_dump($item);
         if (isset($video_id)) {
             $videoInfo = intelliam_util::getInfoVideoById($video_id, $Video_List_ContentDetails_Statistics);
             echo '<div class="intelliam-thumb" style="width: 175px;">';
             echo '<a class="intelliam-cursor-pointer video-item" id="' . $video_id . '">';
             echo '<img class="intelliam-thumbnail-image" width="167" height="94" src="' . $item->snippet->thumbnails->medium->url . '" alt="' . $item->snippet->title . '">';
             echo '</a>';
             echo '<dl class="intelliam-meta-group" style="width: 167px;">';
             echo '<dd class="intelliam-meta-title"><a class="intelliam-cursor-pointer video-item" id="' . $video_id . '">' . $item->snippet->title . '</a></dd>';
             echo '<dd class="intelliam-meta-duration">' . intelliam_util::ISO8601_To_duration($videoInfo->contentDetails->duration) . '</dd>';
             echo '<dt>View count</dt>';
             echo '<dd>' . $videoInfo->statistics->viewCount . '</dd>';
             echo '</dl>';
             echo '</div>';
         }
     }
     echo '</div>';
 }
function create_shortcode()
{
    $option = get_option('ta_videobook_setting');
    //Default Googke Key
    $GoogleKey = 'AIzaSyBZqdpiCXFQqHI4h90fFfbkiaZSPquqhjM';
    //Default Playlist
    $PlayListID = 'PLKbMO3RbT7Pd9XQWaFRBCR5wb_wcrSgL5';
    if (isset($option['google_key']) && !is_null($option['google_key'])) {
        $GoogleKey = $option['google_key'];
    }
    if (isset($option['playlistID']) && !is_null($option['playlistID'])) {
        $PlayListID = $option['playlistID'];
    }
    $YouTube_v3 = new Youtube($GoogleKey);
    $Number_Video_Of_Page = 12;
    // 1 - Lay trang hi?n t?i
    $Current_Page = isset($_GET['vdPage']) ? $_GET['vdPage'] : 1;
    // 2 - Lay thong tin PlayList
    //   Bao nhieu Video de Phan trang
    $playList = $YouTube_v3->getPlaylistById($PlayListID, ['contentDetails']);
    $Video_Items_Count = $playList->contentDetails->itemCount;
    if ($Video_Items_Count == 0) {
        echo 'No video in the playlist';
        return;
    }
    $count_pages = ceil($Video_Items_Count / 12);
    //echo 'So luong video trong playlist la: ' . $Video_Items_Count;
    $KetQua = "";
    echo '<div style="width: 700px;">';
    //echo var_dump($playList);
    // 3 - Lay danh sach video t? playlist
    $playlistItems = [];
    $nextPageToken = "";
    for ($index = 0; $index < $count_pages; $index++) {
        $pageNumber = $index + 1;
        if ($pageNumber == $Current_Page) {
            $playlistItems = $YouTube_v3->getPlaylistItemsByPlaylistId($PlayListID, $nextPageToken, $Number_Video_Of_Page, ['id', 'snippet']);
            break;
        } else {
            $nextPageToken = is_null($nextPageToken) ? true : $nextPageToken;
            $playlistItems = $YouTube_v3->getPlaylistItemsByPlaylistId($PlayListID, $nextPageToken, $Number_Video_Of_Page, ['id']);
            $nextPageToken = $playlistItems['info']['nextPageToken'];
        }
    }
    // 4 - Hien thi Video player
    $first_video = $playlistItems['results'][0];
    $first_video_id = $first_video->snippet->resourceId->videoId;
    $first_Video_Player = $YouTube_v3->getVideoInfo($first_video_id, ['player']);
    echo '<div class="intelliam-normal-player" style="width: 100%">';
    //echo '<div class="intelliam-big-title">' . $first_video->snippet->title . '</div>';
    echo '<div class="intelliam-fluid-width-video-wrapper" id="video-container"><div class="fluid-width-video-wrapper" style="padding-top: 55%">' . $first_Video_Player->player->embedHtml . '</div></div>';
    echo '</div>';
    //Hien thi phan trang
    intelliam_util::displayPagination($count_pages, $Current_Page);
    // Lay Danh sach Id cua tat ca video
    $VideoId_List = intelliam_util::getVideoIdList($playlistItems['results']);
    // Lay Danh thong tin video tu danh sach
    $Video_List_ContentDetails_Statistics = $YouTube_v3->getVideoInfo($VideoId_List, ['contentDetails', 'statistics']);
    //Hien Thi danh sach video
    intelliam_util::displayVideoList($playlistItems['results'], $Video_List_ContentDetails_Statistics);
    //Hien thi phan trang
    intelliam_util::displayPagination($count_pages, $Current_Page);
    echo '</div>';
    //return $KetQua;
}