<?php
$login = query_string('1');
$player = query_string('2');
//$servidor = code_decode(query_string('5'),"D");
$aspectratio = query_string('6');
$capa_vodthumb = code_decode(query_string('7'),"D");
$vod = code_decode(query_string('8'),"D");

$verifica_stm = mysqli_num_rows(mysqli_query($conexao,"SELECT * FROM streamings where login = '".$login."'"));

if($verifica_stm == 0) {
die ("Error! Missing data.");
}

$dados_config = mysqli_fetch_array(mysqli_query($conexao,"SELECT * FROM configuracoes"));
$dados_stm = mysqli_fetch_array(mysqli_query($conexao,"SELECT * FROM streamings where login = '".$login."'"));
$dados_servidor = mysqli_fetch_array(mysqli_query($conexao,"SELECT * FROM servidores where codigo = '".$dados_stm["codigo_servidor"]."'"));

if($dados_servidor["nome_principal"]) {
$servidor = $dados_servidor["nome_principal"].".".$dados_config["dominio_padrao"];
} else {
$servidor = $dados_servidor["nome"].".".$dados_config["dominio_padrao"];
}

$url_source = "https://".$servidor."/".$login."/_definst_/mp4:".$vod."/playlist.m3u8";
$url_source_videojs = "https://".$servidor."/".$login."/".$login."/mp4:".$vod."/playlist.m3u8";


?>

<?php if($player == 1) { ?>
<?php $autoplay = (query_string('3') == "true") ? "autoplay" : "";  ?>
<?php $mudo = (query_string('4') == "true") ? "muted" : "";  ?>
<?php $loop = (query_string('9') == "true") ? "loop" : "";  ?>
<html>
    <!--[if IE 8]>
    <html lang="en" class="ie8 no-js"> <![endif]--><!--[if IE 9]>
    <html lang="en" class="ie9 no-js"> <![endif]--><!--[if !IE]>
    <html lang="en" class="no-js"> <!--<![endif]-->
    <head>
        <meta charset=utf-8 />
        <meta name=author content=Streaming>
<meta name=description content="Streaming">
<meta name=apple-touch-fullscreen content=yes>
<meta name=apple-mobile-web-app-capable content=yes>
<meta name=viewport content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
<meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1">
<link href="//vjs.zencdn.net/7.8.3/video-js.css" rel="stylesheet">
 <style>*{margin:0}body,html{height:100%}.video-js{height:100%!important}.video-js .vjs-time-control{display:none}.video-js .vjs-progress-control{display:none}.video-js .vjs-menu-button-inline.vjs-slider-active,.video-js .vjs-menu-button-inline:focus,.video-js .vjs-menu-button-inline:hover,.video-js.vjs-no-flex .vjs-menu-button-inline{width:10em}.video-js .vjs-controls-disabled .vjs-big-play-button{z-index: 999999999;display:none!important}.video-js .vjs-control{width:3em}.video-js .vjs-menu-button-inline:before{width:1.5em}.vjs-menu-button-inline .vjs-menu{left:3em}.video-js.vjs-ended .vjs-big-play-button,.video-js.vjs-paused .vjs-big-play-button,.vjs-paused.vjs-has-started.video-js .vjs-big-play-button{display:block}.video-js .vjs-load-progress div,.vjs-seeking .vjs-big-play-button,.vjs-waiting .vjs-big-play-button{display:none!important}.video-js .vjs-mouse-display:after,.video-js .vjs-play-progress:after{padding:0 .4em .3em}.video-js.vjs-ended .vjs-loading-spinner{display:none}.video-js.vjs-ended .vjs-big-play-button{display:block!important}.video-js.vjs-paused .vjs-big-play-button,.vjs-paused.vjs-has-started.video-js .vjs-big-play-button,video-js.vjs-ended .vjs-big-play-button{display:block}.video-js .vjs-big-play-button{top:50%;left:50%;margin-left:-1.5em;margin-top:-1em}.video-js .vjs-big-play-button{background-color:rgba(14,34,61,.7);font-size:3.5em;border-radius:12%;height:1.4em!important;line-height:1.4em!important;margin-top:-.7em!important;z-index: 999999999;}.video-js .vjs-big-play-button:active,.video-js .vjs-big-play-button:focus,.video-js:hover .vjs-big-play-button{background-color:#0e223d}.video-js .vjs-loading-spinner{border-color:rgba(14,34,61,.84)}.video-js .vjs-control-bar2{background-color:#0e223d}.video-js .vjs-control-bar{background-color:#0e223d!important;color:#fff;font-size:14px;z-index: 999999999;}.video-js .vjs-play-progress,.video-js .vjs-volume-level{background-color:rgba(14,34,61,.8)}.vjs-watermark{position:absolute;display:inline;z-index:2000}</style>
</head>
<body>
<video id="player_webtv" class="video-js vjs-big-play-centered vjs-fluid" <?php echo $autoplay; ?> <?php echo $mudo; ?> <?php echo $loop; ?> poster="<?php echo $capa_vodthumb; ?>" controls preload="auto" width="100%" height="100%" data-setup="{ 'fluid':true,'aspectRatio':'<?php echo $aspectratio; ?>' }" >
   <source src="<?php echo $url_source_videojs; ?>" type="application/x-mpegURL">
</video>
    <script src="https://vjs.zencdn.net/7.8.3/video.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/@videojs/http-streaming@1.10.3/dist/videojs-http-streaming.min.js"></script>
<script>var myPlayer=videojs('player_webtv',{},function(){var player=this;player.on("pause",function(){player.one("play",function(){player.load();player.play();});});})</script>
</body>
</html>
<?php } elseif($player == 2) { ?>
<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <script type="text/javascript" charset="utf-8" src="//cdn.jsdelivr.net/npm/clappr@latest/dist/clappr.min.js"></script>
  <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  <title>Player</title>
<style>*{margin:0;}html,body{height:100%;}</style>
</head>
<body>
<div  class="container-fluid">
    <div class="row">
    	<?php if($aspectratio == "16:9") { ?>
        <div class="embed-responsive embed-responsive-16by9">
        <?php } ?>
    	<?php if($aspectratio == "4:3") { ?>
        <div class="embed-responsive embed-responsive-4by3">
        <?php } ?>
        <div id="player_webtv" class="embed-responsive-item"></div>
        </div>
</div>
</div>
    <script type="text/javascript" charset="utf-8">
  window.onload = function() {
  var player = new Clappr.Player({
    source: '<?php echo $url_source; ?>',
    parentId: '#player_webtv',
	width: '100%',
    height: '100%',
    mute: <?php echo query_string('4'); ?>,
    hideMediaControl: true,
    poster: '<?php echo $capa_vodthumb; ?>',
	loop: '<?php echo query_string('9'); ?> ',
	autoPlay: <?php echo query_string('3'); ?>  });
}
  </script>
</body>
</html>
<?php } else { ?>
<!DOCTYPE html>
<html lang="pt-BR">
<head>
	<title>Player</title>
	<script src="https://content.jwplatform.com/libraries/5PLwmcI5.js"></script>
</head>
<body>
<style>body{margin:0;overflow:hidden;background:#000}.jwplayer{position:inherit!important;}</style>
<div id="video_main"></div>
<script>
var player = jwplayer("video_main");
	player.setup({
		aboutlink: "",
		abouttext: "",
		aspectratio: '<?php echo $aspectratio; ?>',
		width: '100%',
		height: '100%',
		displaytitle: false,
		displaydescription: false,
		logo: {
			hide: true,
		},
		sharing: {},
		mute: <?php echo query_string('4'); ?>,
		autostart: <?php echo query_string('3'); ?>,
		repeat: '<?php echo query_string('9'); ?> ',
		image: '<?php echo $capa_vodthumb; ?>',
		sources: [{"file":"<?php echo $url_source; ?>"}]
	});
</script>	
</body>
</html>
<?php } ?>