简体   繁体   中英

List mp3 files from multiple directories

I have a problem again... My directory structure is:

mp3/
   /CD1/
       /test1.mp3
       /test2.mp3 ...
   /CD2/
       /test3.mp3 ...

I'm trying to get an output such as spotify like, all info taken from the dir structure:

CD1 ---- Songs: test1.mp3 / test2.mp3 / ...

Then scan next folder and output:

CD2 ---- Songs: test3.mp3 / ...

And for succesive folders.

I am able to output ALL files inside the mp3 dir, but thats not what I want.

The admin has to be able to add a new folder "CD3" and the .php page has to show the new folder and its songs.

CD3 ---- Songs: test4.mp3 / ...

I don't know if this is possible... I'm trying to setup the code so that the webpage admin does not need to touch any of the code, but only the file structure.

THANKS!

The idea of what I want is here: http://qalbiol.x10.mx/qalbiol/sounds.php

The above works because I manually set mp3/CD1 as search dir, then set mp3/CD2 as search dir...

I have done something like this for images, not sure if this may help:

$path = WWW.'/images/user-images/public';
if(is_dir($path)){
    $dir1 = opendir($path);

    while($scan = readdir($dir1)){ 
        if(is_dir($path.'/'.$scan) && $scan != '..' && $scan != '.'){
            $dir2 = opendir($path.'/'.$scan);
            $counter = 0;
            while($images = readdir($dir2)){
                if(!is_dir($images) && $images != '..' && $images != '.'){
                    $allImages[$counter] = $images;
                    $counter++;
                }
            }   
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM