Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/10/2013, 07:49
Avatar de el_tigre
el_tigre
 
Fecha de Ingreso: febrero-2006
Ubicación: Perú
Mensajes: 1.044
Antigüedad: 18 años, 2 meses
Puntos: 8
De acuerdo Listar archivos de Sub directorios

Amigos, el siguiente código me permite mostrar un XML una lista de MP3 que encuentra en un directorio...

(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";


?>
El otro archivo necesario es (1.php):

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>
Cuando pongo la ruta por ejemplo:

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.