aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/helper.php58
-rw-r--r--pages/room.php47
-rw-r--r--template/assemblies/desktop-player.phtml6
-rw-r--r--template/assemblies/switcher/video.phtml98
4 files changed, 144 insertions, 65 deletions
diff --git a/lib/helper.php b/lib/helper.php
index 87bd6c5..647d657 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -14,9 +14,9 @@ function link_room($room)
function link_player($room, $format = 'hd', $translated = false)
{
- $isDefaultFormat = in_array($format, array('hd', 'video'));
+ $defaultformat = room_has_hd($room) ? 'hd' : 'sd';
- return rawurlencode($room).'/'.($isDefaultFormat ? '' : rawurlencode($format).'/').($translated ? 'translated/' : '');
+ return rawurlencode($room).'/'.($defaultformat == $format ? '' : rawurlencode($format).'/').($translated ? 'translated/' : '');
}
function link_stream($protocol, $room, $format, $translated = false)
@@ -134,3 +134,57 @@ function _get($array, $keychain, $default)
return _get($array[$key], array_slice($keychain, 1), $default);
}
+
+
+
+function room_has_hd($room)
+{
+ $formats = get("ROOMS.$room.FORMATS");
+ return count(array_intersect(array('rtmp-hd', 'hls-hd', 'webm-hd'), $formats)) > 0;
+}
+
+function room_has_sd($room)
+{
+ $formats = get("ROOMS.$room.FORMATS");
+ return count(array_intersect(array('rtmp-sd', 'hls-sd', 'webm-sd'), $formats)) > 0;
+}
+
+function room_has_video($room)
+{
+ return room_has_hd($room) || room_has_sd($room);
+}
+
+function room_has_audio($room)
+{
+ $formats = get("ROOMS.$room.FORMATS");
+ return count(array_intersect(array('audio-mp3', 'audio-opus'), $formats)) > 0;
+}
+
+function room_has_slides($room)
+{
+ $formats = get("ROOMS.$room.FORMATS");
+ return count(array_intersect(array('slides'), $formats)) > 0;
+}
+
+function room_has_rtmp($room)
+{
+ $formats = get("ROOMS.$room.FORMATS");
+ return count(array_intersect(array('rtmp-hd', 'rtmp-sd'), $formats)) > 0;
+}
+
+function room_has_webm($room)
+{
+ $formats = get("ROOMS.$room.FORMATS");
+ return count(array_intersect(array('webm-hd', 'webm-sd'), $formats)) > 0;
+}
+
+function room_has_hls($room)
+{
+ $formats = get("ROOMS.$room.FORMATS");
+ return count(array_intersect(array('hls-hd', 'hls-sd'), $formats)) > 0;
+}
+
+function startswith($needle, $haystack)
+{
+ return substr($haystack, 0, strlen($needle)) == $needle;
+}
diff --git a/pages/room.php b/pages/room.php
index ba4e35b..526aabd 100644
--- a/pages/room.php
+++ b/pages/room.php
@@ -8,35 +8,47 @@ $language = $_GET['language'];
$selection = $_GET['selection'];
$formats = get("ROOMS.$room.FORMATS");
+$has_translation = get("ROOMS.$room.TRANSLATION");
+$protos = array();
$selections = array();
$tabs = array();
+$videores = array();
+if(room_has_hd($room))
+ $selections[] = $videores[] = 'hd';
-if(count(array_intersect(array('rtmp-hd', 'hls-hd', 'webm-hd'), $formats)) > 0)
- $selections[] = 'hd';
+if(room_has_sd($room))
+ $selections[] = $videores[] = 'sd';
-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)
+if(room_has_video($room))
$tabs[] = 'video';
-if(count(array_intersect(array('audio-mp3', 'audio-opus'), $formats)) > 0)
+
+if(room_has_audio($room))
$selections[] = $tabs[] = 'audio';
-if(count(array_intersect(array('slides'), $formats)) > 0)
+if(room_has_slides($room))
$selections[] = $tabs[] = 'slides';
+if(room_has_rtmp($room))
+ $protos[] = 'rtmp';
+
+if(room_has_webm($room))
+ $protos[] = 'webm';
+
+if(room_has_hls($room))
+ $protos[] = 'hls';
+
+
// default page
if(!$selection)
$selection = $selections[0];
-if(!in_array($selection, $selections)) {
- include('404.php');
- exit;
-}
+if(!in_array($selection, $selections))
+ return include('404.php');
+
switch($selection) {
@@ -53,6 +65,8 @@ switch($selection) {
case 'slides':
$tab = 'slides';
$title = 'Slides';
+ $width = 1024;
+ $height = 576;
break;
case 'hd':
@@ -71,7 +85,12 @@ switch($selection) {
}
if($language == 'translated')
+{
+ if(!$has_translation)
+ return include('404.php');
+
$title = 'Translated '.$title;
+}
echo $tpl->render(array(
'page' => 'room',
@@ -90,5 +109,9 @@ echo $tpl->render(array(
'translated' => ($language == 'translated'),
'selection' => $selection,
'hlsformat' => ($selection == 'hd' ? 'auto' : $selection),
+
+ 'has_translation' => $has_translation,
'formats' => $formats,
+ 'protos' => $protos,
+ 'videores' => $videores,
));
diff --git a/template/assemblies/desktop-player.phtml b/template/assemblies/desktop-player.phtml
index 5836f90..b317abd 100644
--- a/template/assemblies/desktop-player.phtml
+++ b/template/assemblies/desktop-player.phtml
@@ -1,2 +1,4 @@
-<h3>Use a Desktop-Player!</h3>
-<p>Browsers and Video doesn't go together well, even in 2014 and especially when it's live. So for your best viewing-experience please use a Desktop-Player like VLC or mplayer.</p>
+<div class="desktop-player-hint">
+ <h3>Use a Desktop-Player!</h3>
+ <p>Browsers and Video doesn't go together well, even in 2014 and especially when it's live. So for your best viewing-experience please use a Desktop-Player like VLC or mplayer.</p>
+</div>
diff --git a/template/assemblies/switcher/video.phtml b/template/assemblies/switcher/video.phtml
index e4fcc5b..a4ac907 100644
--- a/template/assemblies/switcher/video.phtml
+++ b/template/assemblies/switcher/video.phtml
@@ -1,64 +1,64 @@
<h3>Formats</h3>
-<ul>
- <? foreach(array('hd', 'sd') as $iter): ?>
+<ul class="formats">
+ <? foreach($videores as $iter): ?>
<li>
<span class="label filetype" title="<?=h(format_text($iter))?>"><?=h(strtoupper($iter))?></span>
- <a href="<?=h(link_player($room, $iter))?>">
- <span class="fa fa-flag-o"></span>
- native
- </a>
- <a href="<?=h(link_player($room, $iter, true))?>">
- <span class="fa fa-flag"></span>
- translated
- </a>
- </li>
- <? endforeach ?>
-</ul>
-<hr />
-
-<? include("$assemblies/desktop-player.phtml") ?>
+ <? if($has_translation): ?>
-<hr />
-
-<? foreach(array('rtmp', 'hls') as $protocol): ?>
- <h3>Directlinks (<?=h(strtoupper($protocol))?>)</h3>
- <ul>
- <?
- if($protocol == 'hls')
- $formats = array('hd', 'sd', 'auto');
- else
- $formats = array('hd', 'sd');
- ?>
- <? foreach($formats as $iter): ?>
- <li>
- <span class="label filetype" title="<?=h(format_text($iter))?>"><?=h(strtoupper($iter))?></span>
- <a href="<?=h(link_stream($protocol, $room, $iter))?>">
+ <a href="<?=h(link_player($room, $iter))?>">
<span class="fa fa-flag-o"></span>
native
</a>
- <a href="<?=h(link_stream($protocol, $room, $iter, true))?>">
+ <a href="<?=h(link_player($room, $iter, true))?>">
<span class="fa fa-flag"></span>
translated
</a>
- </li>
- <? endforeach ?>
- </ul>
-<? endforeach ?>
-<h3>Directlinks (WebM)</h3>
-<ul>
- <? foreach(array('hd', 'sd') as $iter): ?>
- <li>
- <span class="label filetype" title="<?=h(format_text('webm'))?>"><?=h(strtoupper($iter))?></span>
- <a href="<?=h(link_stream('webm', $room, $iter))?>">
- <span class="fa fa-flag-o"></span>
- native
- </a>
- <a href="<?=h(link_stream('webm', $room, $iter, true))?>">
- <span class="fa fa-flag"></span>
- translated
- </a>
+ <? else: ?>
+
+ <a href="<?=h(link_player($room, $iter))?>">
+ <span class="fa fa-video-camera"></span>
+ video
+ </a>
+
+ <? endif ?>
</li>
<? endforeach ?>
</ul>
+
+<? include("$assemblies/desktop-player.phtml") ?>
+
+<div class="directlinks">
+ <? foreach($protos as $proto): ?>
+ <h3>Directlinks (<?=h(strtoupper($proto))?>)</h3>
+ <ul>
+ <? foreach($formats as $format): ?>
+ <? if(!startswith($proto, $format)) continue ?>
+ <? $res = substr($format, -2) ?>
+ <li>
+ <span class="label filetype" title="<?=h(format_text($res))?>"><?=h(strtoupper($res))?></span>
+ <? if($has_translation): ?>
+
+ <a href="<?=h(link_stream($proto, $room, $res))?>">
+ <span class="fa fa-flag-o"></span>
+ native
+ </a>
+ <a href="<?=h(link_stream($proto, $room, $res, true))?>">
+ <span class="fa fa-flag"></span>
+ translated
+ </a>
+
+ <? else: ?>
+
+ <a href="<?=h(link_stream($proto, $room, $res))?>">
+ <span class="fa fa-video-camera"></span>
+ video
+ </a>
+
+ <? endif ?>
+ </li>
+ <? endforeach ?>
+ </ul>
+ <? endforeach ?>
+</div>