diff options
-rwxr-xr-x | bin/backend.php | 16 | ||||
-rwxr-xr-x | bin/files.php | 22 | ||||
-rwxr-xr-x | bin/jsonapi.php | 17 | ||||
-rwxr-xr-x | bin/session.php | 37 | ||||
-rwxr-xr-x | config_default.php | 8 |
5 files changed, 67 insertions, 33 deletions
diff --git a/bin/backend.php b/bin/backend.php index 9be4b28..971629e 100755 --- a/bin/backend.php +++ b/bin/backend.php @@ -111,19 +111,9 @@ switch ($action) print $tree; break; - case ("browseRec"): - $tree = file_get_contents("textfiles/browseRec.txt"); - print $tree; - break; - - case ("browseAudio"): - $tree = file_get_contents("textfiles/browseAudio.txt"); - print $tree; - break; - case ("streamAudio"): - $tree = file_get_contents("textfiles/streamAudio.txt"); - print $tree; - break; + $tree = streamAudio($_REQUEST['path'], $_REQUEST['file']); + print $tree; + break; } ?> diff --git a/bin/files.php b/bin/files.php index d87d332..30dbe49 100755 --- a/bin/files.php +++ b/bin/files.php @@ -80,15 +80,6 @@ function mediagentb($stream, $dest) exec('cp ../logos/nologoMEDIA.png ' .$dest); } -function mediagetwidth($file) -{ - - $getid3 = new getID3; - $fileinfo = $getid3->analyze($file); - - return $fileinfo['video']['resolution_x']; -} - function filegettype($file) { global $videotypes, $audiotypes; @@ -114,7 +105,7 @@ function filegettype($file) return 'unknown'; } -function mediagetmusicinfo($file ="") +function mediagetmusicinfo($file) { // Get info $getid3 = new getID3; @@ -187,6 +178,8 @@ function filesgetlisting($dir) // Alphabetical sorting sort($medianame_array); + $number = 1; + foreach($medianame_array as $value) { $newentry = array(); @@ -199,18 +192,17 @@ function filesgetlisting($dir) switch ($type) { case 'audio': + list($newentry['trackname'], $newentry['length']) = mediagetmusicinfo($dir ."/" .$value); + $newentry['number'] = $number; + $number++; case 'video': case 'rec': case 'folder': $newentry['type'] = $type; + $listing[] = $newentry; break; default: - continue; - } - - // Add new entry - $listing[] = $newentry; } return $listing; diff --git a/bin/jsonapi.php b/bin/jsonapi.php index d4f96ac..b0e53cb 100755 --- a/bin/jsonapi.php +++ b/bin/jsonapi.php @@ -2,13 +2,13 @@ function getGlobals() { - global $vdrstreamdev, $vdrrecpath, $mediasource; + global $vdrstreamdev, $vdrrecpath, $mediasource, $videosource, $audiosource; $ret = array(); $ret['streamdev_server'] = $vdrstreamdev; $ret['rec_path'] = $vdrrecpath; - $ret['video_path'] = "/home/storage/Foot/"; - $ret['audio_path'] = "/home/www/mp3/"; + $ret['video_path'] = $videosource; + $ret['audio_path'] = $audiosource; return json_encode($ret); } @@ -167,4 +167,15 @@ function browseFolder($path) return json_encode($ret); } + +function streamAudio($path, $file) +{ + $ret = array(); + + $ret['track'] = streammusic($path, $file); + + return json_encode($ret); + +} + ?> diff --git a/bin/session.php b/bin/session.php index 09d793f..e17e166 100755 --- a/bin/session.php +++ b/bin/session.php @@ -262,4 +262,41 @@ function sessiongetlist() return $sessions; } +function streammusic($path, $file) +{ + global $httppath; + + $files = array(); + + // Create all symlinks + exec('mkdir ../playlist'); + exec('rm ../playlist/*'); + exec('ln -s ' .addcslashes(quotemeta($path), " &'") .'/* ../playlist'); + + // Generate files + + // Get listing + $filelisting = filesgetlisting($path); + + $addfiles = 0; + + foreach ($filelisting as $f) + { + if ($f['type'] != 'audio') + continue; + + if ($f['name'] == $file) + $addfiles = 1; + + if ($addfiles) + { + $newfile = array(); + $newfile['file'] = $httppath ."playlist/" . $f['name']; + $files[] = $newfile; + } + } + + return $files; +} + ?> diff --git a/config_default.php b/config_default.php index ebf96fd..fab59dc 100755 --- a/config_default.php +++ b/config_default.php @@ -19,8 +19,12 @@ // 1:vid 2:aud Source name Source path $mediasource=array(); - $mediasources[]=array ( 1, 'Video', '/mnt/media/movies'); - $mediasources[]=array ( 2, 'Audio', '/mnt/media/music'); + $mediasources[]=array ( 1, 'Video', '/mnt/media/movies/'); + $mediasources[]=array ( 2, 'Audio', '/mnt/media/music/'); + + // TEMPORARY + $videosource = '/mnt/media/movies/'; + $audiosource = '/mnt/media/music/'; // Encoding (The name cannot be changed) // Name Video Audio Audio channels Resolution |