用php自动生成播放列表
我使用以下脚本生成播放列表:用php自动生成播放列表,php,Php,我使用以下脚本生成播放列表: <?php $dir = './music'; $url = 'music'; header('Content-type: text/xml'); echo '<?xml version="1.0" encoding="utf-8"?>' . "\n"; echo '<playlist>'; if (is_dir($dir)) { $dp = opendir($dir); while
<?php
$dir = './music';
$url = 'music';
header('Content-type: text/xml');
echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";
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 "\n";
}
}
closedir($dp);
}
echo '</playlist>';
看看这个库
这将获得艺术家、标题以及长度。您需要解析文件并提取数据。它不能给你任何更多的信息,因为你没有指出ID3版本(有几个)。有关于ID3v1和v2之间差异的信息
一个更好的选择是使用一个库,比如或也可以看看这个网站
您也可以在此处使用此功能读取mp3 id3标签:
如果你没有意识到,你实际上不需要这些标签来让它工作。