<?php
global $fm, $config, $str, $settings;

if ($_GET['stream']) {
	$fm->sendFileToBrowser($data['filePath']);
	exit();
}

$getID3 = new getID3;
$fInfo = $getID3->analyze($data['filePath']);

$path = str_replace('&', '%26', $str->fromHTML($_REQUEST['path']));
$filename = str_replace('&', '%26', $str->fromHTML($_REQUEST['filename']));

$URL = $config['url']['root']."/";
$URL .= $str->forURL("?");
$URL .= "module=fileman";
$URL .= $str->forURL("&");
$URL .= "section=utils";
$URL .= $str->forURL("&");
$URL .= "page=file_preview";
$URL .= $str->forURL("&");
$URL .= "path=".$str->forURL($path);
$URL .= $str->forURL("&");
$URL .= "filename=".$str->forURL($filename);
$URL .= $str->forURL("&");
$URL .= "stream=1";
?>
<html>
<head>
	<title></title>
	<style>
		body {
			background-color: black;
			border: 0px;
			margin: 0px;
			padding: 0px;
			overflow:hidden;
		}
	</style>
	<script type="text/javascript" charset="utf-8" src="<?php echo $config['url']['root']?>/js/swfobject/swfobject.js?v=<?php echo $settings->currentVersion;?>"></script>
</head>

<body>
	<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%" style="height:100%" border="0">
	<tr>
		<td align="center" valign="middle">
		<div id="videoPlayer" style="width:100%;height:100%;"></div>
		<script type="text/javascript">
			var videoSize = {
				width: parseInt('<?php echo $fInfo['video']['resolution_x']?:0; ?>'),
				height: parseInt('<?php echo $fInfo['video']['resolution_y']?:0; ?>')
			};
			if (videoSize.width < 100 || videoSize.width > window.innerWidth) {
				videoSize.width = '100%';
			}
			if (videoSize.height < 100 || videoSize.width > window.innerHeight) {
				videoSize.height = '100%';
			}
			var flashVars = {
				video: "<?php echo $URL?>",
				skin: '<?php echo $config['url']['root']?>/viewers/flv/mySkin.swf?v=<?php echo $settings->currentVersion;?>',
				autoplay: 1,
				menu: false,
			};
			var params = {
				allowFullScreen: true,
				wmode: 'window',
				quality: 'high'
			}
			swfobject.embedSWF("<?php echo $config['url']['root']?>/viewers/flv/player.swf?v=<?php echo $settings->currentVersion;?>", "videoPlayer", videoSize.width, videoSize.height, "9.0.0", "js/swfobjectexpressInstall.swf", flashVars, params);
		</script>
		</td>
	</tr>
	</table>
</body>
</html>