summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlib <aliboba@free.fr>2010-02-25 00:30:24 +0100
committerAlib <aliboba@free.fr>2010-02-25 00:30:24 +0100
commit0f2b4641c3c8f4fbb9f4d48d34a6cd06fc64e13b (patch)
treeed000ac16f0b74acba516653f4cad4857b51d579
parentdabff11bcdaf22ae9f2df6dd50aef866cfdbbc42 (diff)
downloadistreamdev-0f2b4641c3c8f4fbb9f4d48d34a6cd06fc64e13b.tar.gz
istreamdev-0f2b4641c3c8f4fbb9f4d48d34a6cd06fc64e13b.tar.bz2
ajax based m3u playlist generation
-rwxr-xr-xincludes/inc_audio.php29
-rwxr-xr-xjavascript/ajax.js29
2 files changed, 32 insertions, 26 deletions
diff --git a/includes/inc_audio.php b/includes/inc_audio.php
index 85d3d64..0c2d358 100755
--- a/includes/inc_audio.php
+++ b/includes/inc_audio.php
@@ -36,9 +36,6 @@ if ($medianame_array[0])
// Alphabetical sorting
sort($medianame_array);
- exec('rm playlist/*');
- exec('ln -s ' .addcslashes(quotemeta($mediapath .$subdir), " &") .'* playlist');
-
$count = count($medianame_array);
for ($cnt=0; $cnt < $count; $cnt++)
@@ -66,7 +63,7 @@ if ($medianame_array[0])
if (mediagettype($mediapath .$subdir .$medianame_array[$cnt]) == 2)
{
print " <li>\r\n";
- print " <a class=\"noeffect\" href=\"javascript:document.s{$idx}.Play();\">\r\n";
+ print " <a class=\"noeffect\" href=\"javascript:playmusic('{$mediapath}{$subdir}','{$medianame_array[$cnt]}');\">\r\n";
print " <span class=\"number\">$idx</span><span class=\"stop\"></span><span class=\"name\">{$medianame_array[$cnt]}</span>\r\n";
print " </a>\r\n";
print " </li>\r\n";
@@ -78,31 +75,11 @@ if ($medianame_array[0])
print("</div>");
print "<div style=\"position:absolute; left:0; top:0\">\r\n";
- $idx = 1;
- for ($cnt=0; $cnt < $count; $cnt++)
- {
- // Audio files
- if (mediagettype($mediapath .$subdir .$medianame_array[$cnt]) == 2)
- {
- print "<embed enablejavascript=\"true\" autoplay=\"false\" height=\"0\" name=\"s{$idx}\"";
- print " src=\"{$httppath}playlist/{$medianame_array[$cnt]}\"";
+ print "<embed enablejavascript=\"true\" autoplay=\"false\" height=\"0\" name=\"player\"";
+ print " src=\"{$httppath}playlist/playlist.m3u\"";
print " width=\"0\" loop=\"true\" controller=\"false\"";
-
- $next=1;
- for ($cnt2=$idx+1; $cnt2<$count; $cnt2++)
- {
- if (mediagettype($mediapath .$subdir .$medianame_array[$cnt2]) == 2)
- {
- print " qtnext{$next}=\"<{$httppath}playlist/{$medianame_array[$cnt2]}>\"";
- $next++;
- }
- }
-
print " />\r\n";
- $idx++;
- }
- }
print("</div>");
}
else
diff --git a/javascript/ajax.js b/javascript/ajax.js
index 7ccafe2..a33bdf9 100755
--- a/javascript/ajax.js
+++ b/javascript/ajax.js
@@ -25,3 +25,32 @@ function alert_ajax(xhr)
swapPic();
}
}
+
+function playmusic(path,name)
+{
+ var xhr=null;
+
+ xhr = new XMLHttpRequest();
+ //on définit l'appel de la fonction au retour serveur
+ xhr.onreadystatechange = function() { openpls(xhr); };
+
+ xhr.open("GET", "genplaylist.php?path=" + path + "&name=" + name, true);
+ xhr.send(null);
+
+}
+
+function openpls(xhr)
+{
+ if (xhr.readyState==4)
+ {
+ var docXML= xhr.responseXML;
+ var streamstatus = null;
+ var items = docXML.getElementsByTagName("m3u")
+
+ streamstatus = items.item(0).firstChild.data;
+ if ( streamstatus == 'error' )
+ this.location.href = 'error.php';
+ else
+ document.player.Play()
+ }
+}