简体   繁体   English

列出多个目录中的mp3文件

[英]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: 我正在尝试获取诸如spotify之类的输出,所有信息都来自dir结构:

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

Then scan next folder and output: 然后扫描下一个文件夹并输出:

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

And for succesive folders. 对于成功的文件夹。

I am able to output ALL files inside the mp3 dir, but thats not what I want. 我能够在mp3目录中输出所有文件,但是那不是我想要的。

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”,。php页面必须显示新文件夹及其歌曲。

CD3 ---- Songs: test4.mp3 / ... CD3 ----歌曲: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 我想要的想法在这里: 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... 上面的工作是因为我手动将mp3 / CD1设置为搜索目录,然后将mp3 / CD2设置为搜索目录...

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++;
                }
            }   
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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