room selection handling rewrite

This commit is contained in:
MaZderMind 2015-02-28 19:12:27 +01:00
parent 28a263a689
commit 663a234bb1
4 changed files with 76 additions and 54 deletions

View file

@ -14,7 +14,7 @@ else if(preg_match('@^([^/]+)$@', $route, $m))
{
$_GET = array(
'room' => $m[1],
'selection' => 'hd',
'selection' => '',
'language' => 'native',
);
include('pages/room.php');
@ -24,7 +24,7 @@ else if(preg_match('@^([^/]+)/translated$@', $route, $m))
{
$_GET = array(
'room' => $m[1],
'selection' => 'hd',
'selection' => '',
'language' => 'translated',
);
include('pages/room.php');

View file

@ -2,54 +2,76 @@
require_once('lib/bootstrap.php');
$room = $_GET['room'];
$language = $_GET['language'];
$selection = $_GET['selection'];
$formats = get("ROOMS.$room.FORMATS");
$selections = array();
$tabs = array();
if(count(array_intersect(array('rtmp-hd', 'hls-hd', 'webm-hd'), $formats)) > 0)
$selections[] = 'hd';
if(count(array_intersect(array('rtmp-sd', 'hls-sd', 'webm-sd'), $formats)) > 0)
$selections[] = 'sd';
if(count(array_intersect(array('rtmp-sd', 'rtmp-hd', 'hls-sd', 'hls-hd', 'webm-sd', 'webm-hd'), $formats)) > 0)
$tabs[] = 'video';
if(count(array_intersect(array('audio-mp3', 'audio-opus'), $formats)) > 0)
$selections[] = $tabs[] = 'audio';
if(count(array_intersect(array('slides'), $formats)) > 0)
$selections[] = $tabs[] = 'slides';
// default page
if(!$selection)
$selection = $selections[0];
if(!in_array($selection, $selections)) {
include('404.php');
exit;
}
switch($selection) {
case 'audio':
$type = 'audio';
$tab = 'audio';
$title = 'Audio';
break;
case 'music':
$type = 'audio';
$tab = 'audio';
$title = 'Music';
break;
case 'slides':
$type = 'slides';
$tab = 'slides';
$title = 'Slides';
break;
case 'hd':
$type = 'video';
$tab = 'video';
$title = 'FullHD Video';
$width = 1920;
$height = 1080;
break;
case 'sd':
$type = 'video';
$tab = 'video';
$title = 'SD Video';
$width = 1024;
$height = 576;
break;
}
$formats = get("ROOMS.$room.FORMATS");
$types = array();
if(count(array_intersect(array('rtmp-sd', 'rtmp-hd', 'hls-sd', 'hls-hd', 'webm-sd', 'webm-hd'), $formats)) > 0)
$types[] = 'video';
if(count(array_intersect(array('audio-mp3', 'audio-opus'), $formats)) > 0)
$types[] = 'audio';
if(count(array_intersect(array('slides'), $formats)) > 0)
$types[] = 'slides';
if($language == 'translated')
$title = 'Translated '.$title;
echo $tpl->render(array(
'page' => 'room',
@ -59,8 +81,8 @@ echo $tpl->render(array(
'program' => program(),
'type' => $type,
'types' => $types,
'tab' => $tab,
'tabs' => $tabs,
'width' => @$width,
'height' => @$height,
@ -68,8 +90,5 @@ echo $tpl->render(array(
'translated' => ($language == 'translated'),
'selection' => $selection,
'hlsformat' => ($selection == 'hd' ? 'auto' : $selection),
// miniroom = no translation, no slides, no irc, no program
// -> sendezentrum, workshops
'miniroom' => in_array($room, array('sendezentrum')),
'formats' => $formats,
));

View file

@ -5,27 +5,30 @@
width="<?=h($width)?>"
height="<?=h($height)?>"
style="width: 100%; height: 100%;"
class="<?=h($miniroom ? 'nosubs' : 'subs')?>"
>
<? if(!$translated): ?>
<? if(in_array("webm-$selection", $formats)): ?>
<source
data-plugin-type="native"
src="<?=h(link_stream('webm', $room, $format, $translated))?>"
src="<?=h(link_stream('webm', $room, $selection, $translated))?>"
title="WebM (Icecast)"
type="video/webm"
/>
<? endif ?>
<source
data-plugin-type="flash"
src="<?=h(link_stream('rtmp', $room, $format, $translated))?>"
title="h.264 (RTMP)"
type="video/rtmp"
/>
<? if(in_array("hls-$selection", $formats)): ?>
<source
data-plugin-type="native"
src="<?=h(link_stream('hls', $room, $hlsformat, $translated))?>"
title="h.264 (HLS)"
type="application/vnd.apple.mpegURL"
/>
<? endif ?>
<? if(in_array("rtmp-$selection", $formats)): ?>
<source
data-plugin-type="flash"
src="<?=h(link_stream('rtmp', $room, $selection, $translated))?>"
title="h.264 (RTMP)"
type="video/rtmp"
/>
<? endif ?>
</video>
</div>

View file

@ -1,14 +1,14 @@
<div class="container <?=h($type)?> <?=h($selection)?> <?=h($language)?>">
<div class="container <?=h($tab)?> <?=h($selection)?> <?=h($language)?>">
<div class="row headline">
<div class="col-xs-12">
<h1 data-room="<?=h(get("ROOMS.$room.DISPLAY"))?>"><?=h($title)?></h1>
</div>
</div>
<ul class="nav nav-tabs nav-justified">
<? foreach($types as $iter): ?>
<ul class="nav nav-player nav-tabs nav-justified">
<? foreach($tabs as $iter): ?>
<li
<? if($type == $iter):?>class="active"<? endif ?>
<? if($tab == $iter):?>class="active"<? endif ?>
>
<a href="<?=h(link_player($room, $iter))?>">
<?=h(ucfirst($iter))?>
@ -19,11 +19,11 @@
<div class="player-wrap tab-content">
<div class="tab-pane active">
<? include("$assemblies/player/$type.phtml") ?>
<? include("$assemblies/player/$tab.phtml") ?>
</div>
</div>
<ul class="nav nav-tabs nav-justified" role="tablist">
<ul class="nav nav-functions nav-tabs nav-justified" role="tablist">
<li class="active">
<a href="#switcher" role="tab" data-toggle="tab">Formats</a>
</li>
@ -44,9 +44,9 @@
<? endif ?>
</ul>
<div class="tab-content">
<div class="functions-wrap tab-content">
<div class="tab-pane active" id="switcher">
<? include("$assemblies/switcher/$type.phtml") ?>
<? include("$assemblies/switcher/$tab.phtml") ?>
</div>
<? if(get("ROOMS.$room.SCHEDULE") && has("SCHEDULE")): ?>
<div class="tab-pane" id="irc">