summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheTroll <trolldev@gmail.com>2010-02-24 16:07:12 +0100
committerTheTroll <trolldev@gmail.com>2010-02-24 16:07:12 +0100
commit434ac8390a4ca5629a070ddb00e88d534a813eee (patch)
tree66ffcff9254280b8c75765043ce5a91f7452fcca
parent6d2af1fac7bd066b75ebd237cc538e29fd21b729 (diff)
downloadistreamdev-434ac8390a4ca5629a070ddb00e88d534a813eee.tar.gz
istreamdev-434ac8390a4ca5629a070ddb00e88d534a813eee.tar.bz2
Now support playing a full dir (still buggy)
inc_home.php cleanup
-rwxr-xr-xincludes/inc_media.php50
-rwxr-xr-x[-rw-r--r--]includes/inc_mp3.php76
-rwxr-xr-xincludes/inc_stream.php2
-rwxr-xr-xincludes/include.php76
-rwxr-xr-x[-rw-r--r--]streammusic.php14
5 files changed, 128 insertions, 90 deletions
diff --git a/includes/inc_media.php b/includes/inc_media.php
index 9da2798..fe09f32 100755
--- a/includes/inc_media.php
+++ b/includes/inc_media.php
@@ -26,11 +26,25 @@ else
print "<div id=\"title\">iStreamdev</div>\r\n";
print "</div>\r\n";
+
print "<div id=\"content\">\r\n";
-print " <span class=\"graytitle\">Media</span>\r\n";
-print "<br>";
-print " <ul class=\"pageitem\">";
-print " <li class=\"textbox\"><span class=\"header\">Current path:</span><p>{$subdir}</p></li>";
+print " <span class=\"graytitle\">Media</span>\r\n";
+print " <br>";
+print " <ul class=\"pageitem\">";
+print " <li class=\"textbox\"><span class=\"header\">Current path:</span><p>{$subdir}</p></li>";
+
+// Option to play dir
+
+if (glob($mediapath .$subdir ."*.mp3"))
+{
+ print " <li class=\"menu\">\r\n";
+ print " <a href=\"index.php?action=playdir&mediapath={$mediapath}&subdir={$subdir}\">\r\n";
+ print " <img src=\"images/pictos/playlist.png\" />\r\n";
+ print " <span class=\"name\">Play current dir</span>\r\n";
+ print " <span class=\"arrow\"></span>\r\n";
+ print " </a>\r\n";
+ print " </li>\r\n";
+}
$dir_handle = @opendir($mediapath .$subdir);
if (!$dir_handle)
@@ -57,7 +71,11 @@ if ($medianame_array[0])
// Directories
if (is_dir($mediapath .$subdir .$value))
{
- print "<li class=\"menu\"><a class=\"noeffect\" href=\"javascript:sendForm('$medianame2');\"><span class=\"name\">$value</span><span class=\"arrow\"></span></a></li>\r\n";
+ print "<li class=\"menu\">\r\n";
+ print " <a class=\"noeffect\" href=\"javascript:sendForm('$medianame2');\">\r\n";
+ print " <span class=\"name\">$value</span><span class=\"arrow\"></span>\r\n";
+ print " </a>\r\n";
+ print "</li>\r\n";
print "<form name=\"$value\" id=\"$value\" method=\"post\" action=\"index.php\">";
print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"media\"/>";
print " <input name=\"mediapath\" type=\"hidden\" id=\"mediapath\" value=\"{$mediapath}\" />";
@@ -70,11 +88,16 @@ if ($medianame_array[0])
$fileext = end(explode(".", $value));
// Check if it is supported
- if ( preg_match("'" .$fileext ." '", $videotypes)
- || preg_match("'" .$fileext ." $'", $videotypes)
+ if ( preg_match("/" .$fileext ." /", $videotypes)
+ || preg_match("/" .$fileext ." $/", $videotypes)
)
{
- print "<li class=\"menu\"><a class=\"noeffect\" href=\"javascript:sendForm('$medianame2');\"><img src=\"images/pictos/video.png\" /><span class=\"name\">$value</span><span class=\"arrow\"></span></a></li>\r\n";
+ print "<li class=\"menu\">\r\n";
+ print " <a class=\"noeffect\" href=\"javascript:sendForm('$medianame2');\">\r\n";
+ print " <img src=\"images/pictos/video.png\" />\r\n";
+ print " <span class=\"name\">$value</span><span class=\"arrow\"></span>\r\n";
+ print " </a>\r\n";
+ print "</li>\r\n";
print "<form name=\"$value\" id=\"$value\" method=\"post\" action=\"index.php\">";
print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"stream\"/>";
print " <input name=\"type\" type=\"hidden\" id=\"type\" value=3 />";
@@ -83,11 +106,16 @@ if ($medianame_array[0])
print " <input name=\"name\" type=\"hidden\" id=\"name\" value=\"{$mediapath}{$subdir}{$value}\" />";
print "</form>\r\n";
}
- else if ( preg_match("'" .$fileext ." '", $audiotypes)
- || preg_match("'" .$fileext ." $'", $audiotypes)
+ else if ( preg_match("/" .$fileext ." /", $audiotypes)
+ || preg_match("/" .$fileext ."$/", $audiotypes)
)
{
- print "<li class=\"menu\"><a href=\"streammusic.php?dir={$mediapath}{$subdir}&file={$value}\"><img src=\"images/pictos/audio.png\" /><span class=\"name\">$value</span><span class=\"arrow\"></span></a></li>\r\n";
+ print "<li class=\"menu\">\r\n";
+ print " <a href=\"streammusic.php?dir={$mediapath}{$subdir}&file={$value}\">\r\n";
+ print " <img src=\"images/pictos/audio.png\" />\r\n";
+ print " <span class=\"name\">$value</span><span class=\"arrow\"></span>\r\n";
+ print " </a>\r\n";
+ print "</li>\r\n";
}
}
}
diff --git a/includes/inc_mp3.php b/includes/inc_mp3.php
index ad84162..f8b2320 100644..100755
--- a/includes/inc_mp3.php
+++ b/includes/inc_mp3.php
@@ -2,26 +2,78 @@
print "<body class=\"ipodlist\">\r\n";
print "<div id=\"topbar\" class=\"transparent\">\r\n";
print "<div id=\"leftnav\">\r\n";
-print " <a href=\"javascript:sendForm('getback')\">Back</a></div>\r\n";
+print " <a href=\"javascript:sendForm('getback')\">Back</a>\r\n";
+print "</div>\r\n";
print "<div id=\"rightnav\">\r\n";
print " <a href=\"index.php\"><img alt=\"home\" src=\"images/home.png\" /></a></div>\r\n";
print "<div id=\"title\">iStreamdev</div>\r\n";
print "</div>\r\n";
print "<div id=\"content\">\r\n";
-print " <ul>";
-print " <li><a class=\"noeffect\" href=\"javascript:document.s1.Play();\">";
-print " <span class=\"number\">1</span><span class=\"auto\"></span><span class=\"name\">Boom Boom Pow</span><span class=\"time\">4:11</span>";
-print " </a></li>";
+print " <ul>\r\n";
-print " <li><a class=\"noeffect\" href=\"javascript:document.s2.Play();\">";
-print " <span class=\"number\">2</span><span class=\"auto\"></span><span class=\"name\">Rock That Body</span><span class=\"time\">4:28</span></a></li>";
+$mediapath = $_REQUEST['mediapath'];
+$subdir = $_REQUEST['subdir'];
-print "</div>\r\n";
+$dir_handle = @opendir($mediapath .$subdir);
+if (!$dir_handle)
+ print "Unable to open $mediapath .$subdir";
+else while ($medianame = readdir($dir_handle))
+{
+ // Add only mp3 files
+
+ if(strstr($medianame, ".mp3") != ".mp3")
+ continue;
+
+ $medianame_array[] = $medianame;
+}
+
+if ($medianame_array[0])
+{
+ // Alphabetical sorting
+ sort($medianame_array);
+
+ $cnt = 1;
+ foreach($medianame_array as $value)
+ {
+ $medianame2=addslashes($value);
+
+ print " <li>\r\n";
+ print " <a class=\"noeffect\" href=\"javascript:document.s{$cnt}.Play();\">\r\n";
+ print " <span class=\"number\">1</span><span class=\"auto\"></span><span class=\"name\">{$value}</span><span class=\"time\">???</span>\r\n";
+ print " </a>\r\n";
+ print " </li>\r\n";
+
+ $cnt++;
+ }
+
+ print "</div>\r\n";
+
+ print "<div style=\"position:absolute; left:0; top:0\">\r\n";
+
+ $count = count($medianame_array);
+ for ($cnt=0; $cnt < $count; $cnt++)
+ {
+ $idx=$cnt+1;
+
+ print "<embed enablejavascript=\"true\" autoplay=\"false\" height=\"0\" name=\"s{$idx}\"";
+ print " src=\"streammusic.php?mediapath={$mediapath}&subdir={$subdir}&file={$medianame_array[$cnt]}\"";
+ print " width=\"0\" loop=\"true\" controller=\"false\"";
+ if (($cnt+1) < $count)
+ print " qtnext1=\"<streammusic.php?mediapath={$mediapath}&subdir={$subdir}&file={$medianame_array[$cnt+1]}\"";
+ print " />\r\n";
+ }
+
+ print "</div>";
+}
+else
+ print "</div>\r\n";
+
+print " <form name=\"getback\" id=\"getback\" method=\"post\" action=\"index.php\">";
+print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"media\" />";
+print " <input name=\"mediapath\" type=\"hidden\" id=\"mediapath\" value=\"{$mediapath}\" />\r\n";
+print " <input name=\"subdir\" type=\"hidden\" id=\"subdir\" value=\"{$subdir}\" />\r\n";
+print " </form>\r\n";
-print "<div style=\"position:absolute; left:0; top:0\">";
-print "<embed enablejavascript=\"true\" autoplay=\"false\" height=\"0\" name=\"s1\" src=\"http://a1.phobos.apple.com/us/r2000/004/Music/22/97/88/mzm.lzzanxzf.aac.p.m4a\" width=\"0\" loop=\"true\" controller=\"false\" qtnext1=\"<http://a1.phobos.apple.com/us/r2000/012/Music/a9/6e/92/mzm.chcdvuzt.aac.p.m4a>\" />";
-print "<embed enablejavascript=\"true\" autoplay=\"false\" height=\"0\" name=\"s2\" src=\"http://a1.phobos.apple.com/us/r2000/012/Music/a9/6e/92/mzm.chcdvuzt.aac.p.m4a\" width=\"0\" />";
-print "</div>";
?>
diff --git a/includes/inc_stream.php b/includes/inc_stream.php
index ff15d51..aa3179b 100755
--- a/includes/inc_stream.php
+++ b/includes/inc_stream.php
@@ -203,7 +203,6 @@ else
print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"listchannels\" />";
print " <input name=\"cat\"type=\"hidden\" id=\"cat\" value=\"{$category}\" />";
break;
- default:
case 2:
$dir = dirname($name);
print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"recordings\" />";
@@ -212,7 +211,6 @@ else
case 3:
$mediapath = $_REQUEST['mediapath'];
$subdir = $_REQUEST['subdir'];
- $dir = dirname($name);
print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"media\" />";
print " <input name=\"mediapath\" type=\"hidden\" id=\"mediapath\" value=\"{$mediapath}\" />\r\n";
print " <input name=\"subdir\" type=\"hidden\" id=\"subdir\" value=\"{$subdir}\" />\r\n";
diff --git a/includes/include.php b/includes/include.php
index 5985ffa..716d1a6 100755
--- a/includes/include.php
+++ b/includes/include.php
@@ -28,32 +28,33 @@ function selectpage()
switch ($action)
{
case ("stream"):
- gen_stream();
+ include('includes/inc_stream.php');
break;
case ("listcategory"):
- gen_category();
+ include('includes/inc_cat.php');
break;
case ("listchannels"):
- gen_channels();
+ include('includes/inc_chan.php');
break;
case ("recordings"):
- gen_recordings();
+ include('includes/inc_rec.php');
break;
case ("media"):
- gen_media();
+ include('includes/inc_media.php');
break;
case ("epg"):
- gen_epg();
+ include('includes/inc_epg.php');
break;
case ("timers"):
- gen_timers();
+ include('includes/inc_timers.php');
break;
case ("edittimer"):
- gen_edit_timer();
+ include('includes/inc_edittimer.php');
break;
case ("deletetimer"):
$timer = $_REQUEST['timer'];
delete_timer($timer);
+ include('includes/inc_timers.php');
break;
case ("addtimer"):
$active = $_REQUEST['timer_active'];
@@ -64,6 +65,7 @@ function selectpage()
$desc = $_REQUEST['timer_name'];
$prevtimer = $_REQUEST['prevtimer'];
set_timer($active, $channame, $date, $stime, $etime, $desc, $prevtimer);
+ include('includes/inc_timers.php');
break;
case ("startstream"):
$type = $_REQUEST['type'];
@@ -77,60 +79,18 @@ function selectpage()
$mediapath = $_REQUEST['mediapath'];
$subdir = $_REQUEST['subdir'];
start_stream($type, $name, $title, $desc, $qname, $qparams, $category, $url, $mediapath, $subdir);
+ include('includes/inc_stream.php');
break;
- default:
- gen_home();
+ case ("playdir"):
+ include('includes/inc_mp3.php');
+ break;
+ default:
+ $_SESSION['currentcat'] = NULL;
+ include('includes/inc_home.php');
break;
}
}
-function gen_home()
-{
- $_SESSION['currentcat'] = NULL;
- include('includes/inc_home.php');
-}
-
-function gen_category()
-{
- include('includes/inc_cat.php');
-}
-
-function gen_channels()
-{
- include('includes/inc_chan.php');
-}
-
-function gen_stream()
-{
- include('includes/inc_stream.php');
-}
-
-
-function gen_recordings()
-{
- include('includes/inc_rec.php');
-}
-
-function gen_media()
-{
- include('includes/inc_media.php');
-}
-
-function gen_epg()
-{
- include('includes/inc_epg.php');
-}
-function gen_timers()
-{
- include('includes/inc_timers.php');
-}
-function gen_edit_timer()
-{
- include('includes/inc_edittimer.php');
-}
-
-
-
function start_stream($type, $name, $title, $desc, $qname, $qparams, $category, $url, $mediapath, $subdir)
{
global $httppath, $ffmpegpath, $segmenterpath;
@@ -181,8 +141,6 @@ function set_timer($active, $channame, $date, $stime, $etime, $desc, $prevtimer)
$message = " <li class=\"textbox\"><p><font color='red'>{$retarray[0]}</font></p></li>";
else
$message = " <li class=\"textbox\"><p>Timer {$settype}ed successfully</p></li>";
-
- include('includes/inc_timers.php');
}
?>
diff --git a/streammusic.php b/streammusic.php
index ab93cce..8dbcbfe 100644..100755
--- a/streammusic.php
+++ b/streammusic.php
@@ -1,16 +1,18 @@
<?php
+
//set headers to mp3
-$dir = $_GET['dir'];
+
+$mediapath = $_GET['mediapath'];
+$subdir = $_GET['subdir'];
$file = $_GET['file'];
+
header("Content-Transfer-Encoding: binary");
header("Content-Type: audio/mp3");
-header('Content-length: ' . filesize($dir.$file));
-header('Content-Disposition: attachment; filename="track.mp3"');
+header('Content-length: ' . filesize($mediapath .$subdir .$file));
+header('Content-Disposition: attachment; filename="streaming.mp3"');
header('X-Pad: avoid browser bug');
Header('Cache-Control: no-cache');
-readfile($dir.$file);
+readfile($mediapath .$subdir .$file);
-$URL="index.php?action=media&dir=$dir";
-header ("Location: $URL");
?>