<?php 
include 'src/vtplugins.php';
$plugins = new VTPlugin();
$plugins->url = 'https://picasaweb.google.com/101650525798379137923/My?authkey=Gv1sRgCNG8zsbUv4yHlgE#6108126474055256546';
$plugins->server = 'picasaweb';
$plugins->on_cache = true;
$arrqt = $plugins->result();
foreach ($arrqt as $key => $value) {
    if ($value['type'] == 'image/gif') {
        $image = 'image: "' . $value['url'] . '",';
    }
    if ($key >= 360) {
        $file[] = (string) '{label: "' . $key . 'p", file: "' . $value['url'] . '/vantoan.mp4"}';
    }
}
$jwplayer = (string) 'sources: [' . @implode(",", $file) . '],';
?>
<html>
	<head>
		<title>Demo JWPlayer - VTPlugins</title>
		<script type="text/javascript" src="./jwplayer/jwplayer.js"></script>
		<script type="text/javascript">jwplayer.key="N8zhkmYvvRwOhz4aTGkySoEri4x+9pQwR7GHIQ=="; // Key bản quyền</script>
	</head>
	<body>
	<div id="myElement">Loading the player...</div>
	<script type="text/javascript">
	    jwplayer("myElement").setup({
	    	primary: 'html5',
	    	<?php 
echo $image;
?>
function player($epid, $type = '')
{
    if ($type != 'video') {
        $episode = MySql::dbselect('id,name,filmid,url,subtitle,thumb,datetime_post,default_subtitle_id', 'episode', "id = '{$epid}'");
        $url = $episode[0][3];
        $subtitles_db = MySql::dbselect('subtitle_lang,subtitle_url,id', 'subtitle', "episode_id = {$epid}");
        $subtitle = $subtitles_db[0][1];
        $nextid = one_data('id', 'episode', "id > '{$epid}' AND filmid = '{$filmid}' AND url LIKE '%" . $link_nxt_type . "%'");
    } else {
        $url = $epid;
    }
    $type_video = type_video($url);
    if (in_array($type_video, array('5', '18', '4'))) {
        $player = "<script type=\"text/javascript\" src=\"/jwplayer/jwplayer.js\"></script>";
        $player .= "<script type=\"text/javascript\">jwplayer.key=\"N8zhkmYvvRwOhz4aTGkySoEri4x+9pQwR7GHIQ==\";</script>";
        include RK_ROOT . '/vtplugins/vtplugins.php';
        $plugins = new VTPlugin();
        $plugins->url = $url;
        if ($type_video == 5) {
            $type_video = 'picasaweb';
        } else {
            if ($type_video = 4 || 18) {
                $type_video = 'youtube';
            }
        }
        $plugins->server = $type_video;
        $plugins->on_cache = true;
        $plugins->key_cache = base64_encode($plugins->url . $plugins->server);
        $arrqt = $plugins->result();
        foreach ($arrqt as $key => $value) {
            if ($value['type'] == 'image/gif') {
                $image = 'image: "' . $value['url'] . '",';
            }
            if ($key >= 360) {
                $file[] = (string) '{label: "' . $key . 'p", file: "' . $value['url'] . '/vantoan.mp4"}';
            }
        }
        $jwplayer = (string) 'sources: [' . @implode(",", $file) . '],';
        if ($subtitle) {
            $subtitle = 'tracks: [{file: "' . $subtitle . '", label: "Tiếng Việt"}],';
        }
        $player .= '<div id="vtplugins">Loading the player...</div>
		<script type="text/javascript">
			jwplayer("vtplugins").setup({
		    	' . $jwplayer . '
				width: "100%",
				height: "100%",
				skin: "/jwplayer/skins/six.xml",
				abouttext: "VTPlugins ' . $plugins->ver . '",
				aboutlink: "http://fb.com/rickypro.info",
				autostart: true,
				' . $subtitle . '
		    });
		</script>';
    } else {
        $player = "<script src=\"" . TEMPLATE_URL . "js/jwplayer5.js\"></script><script>\$(document).ready(function(){onjwplayer('{$url}','{$subtitle}','{$nextid}');});</script>";
    }
    echo $player;
}