(genera.php)
Código PHP:
$filter = ".mp3";
// path to the directory you want to scan
$directory=$_GET['music'];
// read through the directory and filter files to an array
@$d = dir($directory);
if ($d) {
while($entry=$d->read()) {
$ps = strpos(strtolower($entry), $filter);
if (!($ps === false)) {
$items[] = $entry;
}
}
$d->close();
sort($items);
}
// third, the playlist is built in an xspf format
// we'll first add an xml header and the opening tags ..
header("content-type:text/xml;charset=utf-8");
echo "<?xml version='1.0' encoding='UTF-8' ?>\n";
echo "<playlist version='1' xmlns='http://xspf.org/ns/0/'>\n";
echo " <title>Sample PHP Generated Playlist</title>\n";
echo " <info>http://www.jeroenwijering.com/</info>\n";
echo " <trackList>\n";
// .. then we loop through the mysql array ..
for($i=0; $i<sizeof($items); $i++) {
echo " <track>\n";
echo " <annotation>".($i+1).". ".end(explode(".mp3",$items[$i],-1))."</annotation>\n";
echo " <location>".$directory.'/'.$items[$i]."</location>\n";
echo " <info></info>\n";
echo " </track>\n";
}
// .. and last we add the closing tags
echo " </trackList>\n";
echo "</playlist>\n";
?>
Código PHP:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="350" height="500" id="mp3player"
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0">
<param name="movie" value="mp3player.swf?file=genera.php?music=<?php echo $_GET['music'];?>" />
<param name="wmode" value="transparent" flashvars="&config=config.xml" />
<embed src="mp3player.swf?file=genera.php?music=<?php echo $_GET['music'];?>" wmode="transparent" width="350" height="500" name="mp3player"
type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
http://midominio.com/mimusica/1.php?music=MarcosV
Esta me muestra toda la música de un directorio, pero no me muestra de los SUB DIRECTORIOS, ¿si quisiera mostrar la música de los SUBDIRECTORIOS qué tendría que hacer?
¿pueden ayudarme? mi conocimiento es muy limitado sobre PHP.