+ }
+
+ foreach ($container->getContainers() as $subContainer) {
+ $listItems[] = getDirItem(
+ $subContainer->title,
+ pathEncode($fullPath . $subContainer->title) . '/'
+ );
+ }
+
+ foreach ($container->getItemIterator(false) as $item) {
+ mediatombAddFile($listItems, $item);
+ }
+
+ sendListItems($listItems);
+}
+
+function mediatombAddFile(&$listItems, $item)
+{
+ global $host1;
+
+ $di = $item->getDetailedItem();
+ $itemUrl = $item->url;
+ if ($di->mimetype !== 'audio/mpeg') {
+ //noxon iRadio cube does not want to play .ogg files
+ $itemUrl = $host1 . 'transcode-nocache.php'
+ . '?url=' . urlencode($itemUrl);
+ }
+ $listItems[] = getEpisodeItem(
+ $item->title,
+ $itemUrl,
+ '',
+ 'MP3'
+ );
+}
+
+/**
+ * Single file mode - shows directories that only have a single file in them.
+ * Each audio file gets its own virtual directory, containing only the
+ * audio file itself.
+ *
+ * Useful children who want to listen a single story before sleeping,
+ * but the noxon's auto switch-off timer is not exactly at the end of
+ * the story. So the next story starts already, and the kid complains
+ * that it wanted to listen to that as well...
+ */
+function mediatombSingle(Services_MediaTomb $smt, $fullPath, $prefix)
+{
+ $path = substr($fullPath, strlen($prefix));
+
+ $parts = explode('/', $path);
+ $fileMode = false;
+ if (substr(end($parts), 0, 5) == 'file-') {
+ $fileMode = true;
+ $fileTitle = substr(end($parts), 5);
+ $path = substr($path, 0, -strlen($fileTitle) - 5);
+ }
+
+ $container = $smt->getContainerByPath($path);
+ $listItems = array();