我需要一些帮助,已经尝试过,但还没有接近考虑获胜。
我需要在Windows 的 XAMPP(v7.4.5) 上运行ID3 PECL 。
昨天我花了一天时间尝试阅读 PHP.net 网站上的PECL 文章,不幸的是,这对我来说没有多大意义,因为我的知识还没有达到那个水平。我也尝试过寻找 ID3 扩展名的 dll 文件,但找不到任何文件。ID3 PECL 页面只有源文件可供下载。
是否有足够耐心的人可以用更通俗的术语解释这个过程……就我而言,它是愚蠢的吗?
任何和所有的帮助将不胜感激。
编辑
有人可以提供帮助吗?
在 Lelio 的帮助下,我现在有了一种从 MP3 中提取信息的方法,我添加了两行来访问流派和附加图片块。流派块有效。然而,附加图片块没有。
这是保存为名为script-mp3-tag-reader.php的单独 php 文件的更新代码:
<?php
function tagReader($file)
{
$id3v23 = array("TIT2","TALB","TPE1","TRCK","TDRC","TLEN","USLT","TCON","APIC");
$id3v22 = array("TT2","TAL","TP1","TRK","TYE","TLE","ULT","TCO");
$fsize = filesize($file);
$fd = fopen($file,"r");
$tag = fread($fd,$fsize);
$tmp = "";
fclose($fd);
if (substr($tag,0,3) == "ID3")
{
$result['FileName'] = $file;
$result['TAG'] = substr($tag,0,3);
$result['Version'] = hexdec(bin2hex(substr($tag,3,1))).".".hexdec(bin2hex(substr($tag,4,1)));
}
if($result['Version'] == "4.0" || $result['Version'] == "3.0")
{
for ($i=0;$i<count($id3v23);$i++)
{
if (strpos($tag,$id3v23[$i].chr(0))!= FALSE)
{
$pos = strpos($tag, $id3v23[$i].chr(0));
$len = hexdec(bin2hex(substr($tag,($pos+5),3)));
$data = substr($tag, $pos, 9+$len);
for ($a=0;$a<strlen($data);$a++)
{
$char = substr($data,$a,1);
if($char >= " " && $char <= "~")
{
$tmp.=$char;
}
}
if(substr($tmp,0,4) == "TIT2") $result['Title'] = substr($tmp,4);
if(substr($tmp,0,4) == "TALB") $result['Album'] = substr($tmp,4);
if(substr($tmp,0,4) == "TPE1") $result['Artist'] = substr($tmp,4);
if(substr($tmp,0,4) == "TRCK") $result['TrackNo'] = substr($tmp,4);
if(substr($tmp,0,4) == "TDRC") $result['Year'] = substr($tmp,4);
if(substr($tmp,0,4) == "TLEN") $result['Lenght'] = substr($tmp,4);
if(substr($tmp,0,4) == "USLT") $result['Lyric'] = substr($tmp,7);
if(substr($tmp,0,4) == "TCON") $result['Genre'] = substr($tmp,4);
if(substr($tmp,0,4) == "APIC") $result['AttachedPicture'] = substr($tmp,4);
$tmp = "";
}
}
}
if($result['Version'] == "2.0")
{
for ($i=0;$i<count($id3v22);$i++)
{
if (strpos($tag,$id3v22[$i].chr(0))!= FALSE)
{
$pos = strpos($tag, $id3v22[$i].chr(0));
$len = hexdec(bin2hex(substr($tag,($pos+3),3)));
$data = substr($tag, $pos, 6+$len);
for ($a=0;$a<strlen($data);$a++)
{
$char = substr($data,$a,1);
if($char >= " " && $char <= "~")
{
$tmp.=$char;
}
}
if(substr($tmp,0,3) == "TT2") $result['Title'] = substr($tmp,3);
if(substr($tmp,0,3) == "TAL") $result['Album'] = substr($tmp,3);
if(substr($tmp,0,3) == "TP1") $result['Artist'] = substr($tmp,3);
if(substr($tmp,0,3) == "TRK") $result['TrackNo'] = substr($tmp,3);
if(substr($tmp,0,3) == "TYE") $result['Year'] = substr($tmp,3);
if(substr($tmp,0,3) == "TLE") $result['Lenght'] = substr($tmp,3);
if(substr($tmp,0,3) == "ULT") $result['Lyric'] = substr($tmp,6);
if(substr($tmp,0,3) == "TCO") $result['Genre'] = substr($tmp,3);
if(substr($tmp,0,3) == "PIC") $result['AttachedPicture'] = base64_encode(substr($tmp,3));
$tmp = "";
}
}
}
return $result;
}
?>
然后在我的index.php文件中加载并使用上面的 PHP 脚本,如下所示:
<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/script/php/script-mp3-tag-reader.php');
$mp3 = $_SERVER['DOCUMENT_ROOT'].'/media/audio/mp3/test_audio.mp3';
$myResult = tagReader($mp3);
print_r($myResult);
?>
在查看时print_r($myresult);
可以看到信息确实存在并且正确......只是不是附加图像部分。我似乎提取的东西远远超出了需要,并且不知道如何只访问我需要的东西。