e8bbfcb9d9c97b26c8b55d47125df186f1390f6a
[noxon-gateway.git] / src / mediatomb.php
1 <?php
2 require_once 'Services/MediaTomb.php';
3
4 function handleRequestMediatomb($fullPath, $prefix)
5 {
6     global $mediatomb;
7
8     extract($mediatomb);
9     try {
10         $smt = new Services_MediaTomb($user, $pass, $host, $port);
11
12         $path = substr($fullPath, strlen($prefix));
13         $container = $smt->getContainerByPath($path);
14         $listItems = array();
15         addPreviousItem($listItems, $fullPath);
16
17         foreach ($container->getContainers() as $subContainer) {
18             $listItems[] = getDirItem(
19                 $subContainer->title,
20                 pathEncode($fullPath . $subContainer->title) . '/'
21             );
22         }
23
24         foreach ($container->getItemIterator(false) as $item) {
25             $di = $item->getDetailedItem();
26             if ($di->mimetype !== 'audio/mpeg') {
27                 //noxon iRadio cube does not want to play .ogg files
28                 //FIXME: convert to mp3
29                 //$di->location (on the server)
30             }
31             $listItems[] = getEpisodeItem(
32                 $item->title,
33                 $item->url,
34                 '',
35                 'MP3'
36             );
37         }
38     } catch (Exception $e) {
39         sendMessage('Mediatomb error: ' . $e->getMessage());
40         return;
41     }
42
43     sendListItems($listItems);
44 }
45 ?>