From 0f2b4641c3c8f4fbb9f4d48d34a6cd06fc64e13b Mon Sep 17 00:00:00 2001 From: Alib Date: Thu, 25 Feb 2010 00:30:24 +0100 Subject: ajax based m3u playlist generation --- includes/inc_audio.php | 29 +++-------------------------- javascript/ajax.js | 29 +++++++++++++++++++++++++++++ 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 "
  • \r\n"; - print " \r\n"; + print " \r\n"; print " $idx{$medianame_array[$cnt]}\r\n"; print " \r\n"; print "
  • \r\n"; @@ -78,31 +75,11 @@ if ($medianame_array[0]) print(""); print "
    \r\n"; - $idx = 1; - for ($cnt=0; $cnt < $count; $cnt++) - { - // Audio files - if (mediagettype($mediapath .$subdir .$medianame_array[$cnt]) == 2) - { - print "\""; - $next++; - } - } - print " />\r\n"; - $idx++; - } - } print("
    "); } 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() + } +} -- cgit v1.2.3