diff options
author | Alib <aliboba@free.fr> | 2010-02-25 13:39:11 +0100 |
---|---|---|
committer | Alib <aliboba@free.fr> | 2010-02-25 13:39:11 +0100 |
commit | 0921ec0f64d6782076d1e1fb2333cb53c86d279f (patch) | |
tree | 48821410f1eb8332254b46ee22b4d4fce136a426 | |
parent | d350aac197f8ad5ab501c3b25b6543e802de0e47 (diff) | |
download | istreamdev-0921ec0f64d6782076d1e1fb2333cb53c86d279f.tar.gz istreamdev-0921ec0f64d6782076d1e1fb2333cb53c86d279f.tar.bz2 |
trying to debug js array
-rwxr-xr-x | includes/inc_audio.php | 18 | ||||
-rwxr-xr-x | includes/inc_utils.php | 24 | ||||
-rwxr-xr-x | javascript/ajax.js | 8 | ||||
-rwxr-xr-x | javascript/functions.js | 15 |
4 files changed, 54 insertions, 11 deletions
diff --git a/includes/inc_audio.php b/includes/inc_audio.php index df7e401..d8fd09d 100755 --- a/includes/inc_audio.php +++ b/includes/inc_audio.php @@ -37,7 +37,6 @@ if ($medianame_array[0]) sort($medianame_array); $count = count($medianame_array); - for ($cnt=0; $cnt < $count; $cnt++) { // Dirs @@ -63,7 +62,16 @@ if ($medianame_array[0]) if (mediagettype($mediapath .$subdir .$medianame_array[$cnt]) == 2) { print " <li>\r\n"; - print " <a class=\"noeffect\" href=\"javascript:playmusic('{$mediapath}{$subdir}','{$medianame_array[$cnt]}');\">\r\n"; + //print " <a class=\"noeffect\" href=\"javascript:playmusic('{$mediapath}{$subdir}','{$medianame_array[$cnt]}');document.player.Play();\">\r\n"; + + for ($cnt2=$cnt; $cnt2<$count; $cnt2++) + { + $track[$cnt2] = $httppath."playlist/".$medianame_array[$cnt2]; + + } + $jsarray = php2js($track); + + print " <a class=\"noeffect\" href=\"javascript:var myarray = new Array({$jsarray});addplayer(myarray);document.player.Play();\">\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"; @@ -74,11 +82,7 @@ if ($medianame_array[0]) print("</div>"); - print "<div style=\"position:absolute; left:0; top:0\">\r\n"; - print "<embed enablejavascript=\"true\" autoplay=\"false\" height=\"0\" id=\"s1\" name=\"s1\""; - print " src=\"playlist/playlist.m3u\""; - print " width=\"0\" loop=\"true\" controller=\"false\""; - print " />\r\n"; + print "<div style=\"position:absolute; left:0; top:0\" id=\"div_player\">\r\n"; print("</div>"); } diff --git a/includes/inc_utils.php b/includes/inc_utils.php index a984794..541c35b 100755 --- a/includes/inc_utils.php +++ b/includes/inc_utils.php @@ -24,4 +24,28 @@ function is_utf8($str) { } return true; } + +function php2js ($var) { + if (is_array($var)) { + $res = "["; + $array = array(); + foreach ($var as $a_var) { + $array[] = php2js($a_var); + } + return join(",", $array); + } + elseif (is_bool($var)) { + return $var ? "true" : "false"; + } + elseif (is_int($var) || is_integer($var) || is_double($var) || is_float($var)) { + return $var; + } + elseif (is_string($var)) { + return "\"" . addslashes(stripslashes($var)) . "\""; + } + // autres cas: objets, on ne les gère pas + return FALSE; +} + + ?> diff --git a/javascript/ajax.js b/javascript/ajax.js index 40ca661..56e7057 100755 --- a/javascript/ajax.js +++ b/javascript/ajax.js @@ -48,11 +48,11 @@ function openpls(xhr) var items = docXML.getElementsByTagName("m3u") streamstatus = items.item(0).firstChild.data; - if ( streamstatus == 'error' ) + if ( streamstatus == 'error' ) { this.location.href = 'error.php'; - else + } - this.location.href = 'playlist/playlist.m3u'; + //this.location.href = 'playlist/playlist.m3u'; //document.s1.Play(); - } + } } diff --git a/javascript/functions.js b/javascript/functions.js index a708963..39927e4 100755 --- a/javascript/functions.js +++ b/javascript/functions.js @@ -189,4 +189,19 @@ function checkform() }
return true;
+
+}
+
+function addplayer(track) {
+
+
+ playercode= "<embed target='myself' src=track[0] width='0' height='0' autoplay='false' type='audio/mp3' loop='true' controller='false' ";
+
+ for ( var i=1; i=track.length; i+=1 ){
+ playercode += "qtnext" + i + "='<" + track[i] + ">' ";
+
+ }
+ playercode+= "</embed>";
+ document.getElementById('div_player').innerHTML = playercode;
+
}
|