+/**
+ * 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();
+
+ $previous = null;
+ if ($fileMode) {
+ //show single file to play
+ $previous = buildPreviousItem(pathEncode($fullPath));
+ $item = $smt->getSingleItem($container, $fileTitle, false);
+ mediatombAddFile($listItems, $item);
+ } else {
+ $previous = buildPreviousItem(pathEncode('internetradio/' . $path . '/dummy'));
+
+ //browse directory
+ foreach ($container->getItemIterator(false) as $item) {
+ $listItems[] = getDirItem(
+ $item->title,
+ pathEncode($fullPath . 'file-' . $item->title)
+ );