dongyuan8469 2010-02-12 13:05
浏览 81
已采纳

使用php自动生成播放列表

I generate a playlist with following script:

   <?php 
$dir        = './music';
$url        = 'music';

header('Content-type: text/xml');
echo '<?xml version="1.0" encoding="utf-8"?>' . "
";
echo '<playlist>';
if (is_dir($dir)) {
    $dp = opendir($dir);
    while (false !== ($file = readdir($dp))){       
        if ('mp3'==strtolower(substr($file, -3))) {                     
            printf('<sound src="%s/%s" stream="true" soundbuffer="8">%s</sound>', $url, $file, str_replace('_', ' ', substr($file, 0, -4)));
            echo "
";
        }        
    }
    closedir($dp);
}
echo '</playlist>';

How do I get the artist and length from each mp3 file?

Thanks in advance

  • 写回答

4条回答 默认 最新

  • douwaif22244 2010-02-12 13:09
    关注

    You need to parse the file and extract the data. It can't give you any more info as you haven't indicated the ID3 version (and there are several). Wikipedia has information on the diffrences between ID3v1 and v2

    A better option would be to use a library, something like ID3 or getID3

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?