X-Git-Url: https://git.cweiske.de/noxon-gateway.git/blobdiff_plain/5bcb79974dbc81073e80074f0b2ae1a4d8d02269..49f9d0097f92966d8d09cb8eb05708425ea3e5ab:/src/mediatomb.php diff --git a/src/mediatomb.php b/src/mediatomb.php index bdfa4eb..ffc123a 100644 --- a/src/mediatomb.php +++ b/src/mediatomb.php @@ -25,8 +25,12 @@ function mediatombBrowse(Services_MediaTomb $smt, $fullPath, $prefix) $path = substr($fullPath, strlen($prefix)); $container = $smt->getContainerByPath($path); + if ($container === null) { + sendMessage('Error accessing ' . $fullPath); + return; + } + $listItems = array(); - addPreviousItem($listItems, $fullPath); $it = $container->getItemIterator(false); $it->rewind(); @@ -57,7 +61,7 @@ function mediatombBrowse(Services_MediaTomb $smt, $fullPath, $prefix) mediatombAddFile($listItems, $item); } - sendListItems($listItems); + sendListItems($listItems, buildPreviousItem($fullPath)); } function mediatombAddFile(&$listItems, $item) @@ -66,10 +70,16 @@ function mediatombAddFile(&$listItems, $item) $di = $item->getDetailedItem(); $itemUrl = $item->url; - if ($di->mimetype !== 'audio/mpeg') { + if (!clientSupportsType($di->mimetype)) { + //client wants transcoded file //noxon iRadio cube does not want to play .ogg files - $itemUrl = $host1 . 'transcode-nocache.php' - . '?url=' . urlencode($itemUrl); + if (isset($GLOBALS['enableCache']) && $GLOBALS['enableCache']) { + $itemUrl = $host1 . 'transcode-cache.php' + . '?url=' . urlencode($itemUrl); + } else { + $itemUrl = $host1 . 'transcode-nocache.php' + . '?url=' . urlencode($itemUrl); + } } $listItems[] = getEpisodeItem( $item->title, @@ -79,6 +89,20 @@ function mediatombAddFile(&$listItems, $item) ); } +function clientSupportsType($mimetype) +{ + if ($mimetype === 'audio/mpeg') { + return true; + } + $ip = $_SERVER['REMOTE_ADDR']; + if (isset($GLOBALS['clientSupport'][$ip][$mimetype]) + && $GLOBALS['clientSupport'][$ip][$mimetype] === true + ) { + return true; + } + return false; +} + /** * Single file mode - shows directories that only have a single file in them. * Each audio file gets its own virtual directory, containing only the @@ -104,13 +128,14 @@ function mediatombSingle(Services_MediaTomb $smt, $fullPath, $prefix) $container = $smt->getContainerByPath($path); $listItems = array(); + $previous = null; if ($fileMode) { //show single file to play - addPreviousItem($listItems, pathEncode($fullPath)); + $previous = buildPreviousItem(pathEncode($fullPath)); $item = $smt->getSingleItem($container, $fileTitle, false); mediatombAddFile($listItems, $item); } else { - addPreviousItem($listItems, pathEncode('internetradio/' . $path . '/dummy')); + $previous = buildPreviousItem(pathEncode('internetradio/' . $path . '/dummy')); //browse directory foreach ($container->getItemIterator(false) as $item) { @@ -121,6 +146,6 @@ function mediatombSingle(Services_MediaTomb $smt, $fullPath, $prefix) } } - sendListItems($listItems); + sendListItems($listItems, $previous); } ?>