我试图利用Wordpress 3.6对getID3()的支持,但在将ID3标记写入mp3时遇到了问题。这是我正在使用的代码:
if ( ! class_exists( 'getID3' ) ) {
require(ABSPATH.WPINC.'/ID3/getid3.php' );
}
# I had to custom install the write library because WP doesn't include it by default, evidently
getid3_lib::IncludeDependency(TEMPLATEPATH.'/lib/getid3/write.php', __FILE__);
$testfile = "/Users/jplew/Sites/dev.example.com/content/uploads/mp3.mp3";
$tagwriter = new getid3_writetags;
$tagwriter->filename = $testfile;
$tagwriter->tagformats = array('id3v2.4');
$TagData['title'][] = 'My Heart Will Go On';
$TagData['artist'][] = 'Celine Dion';
$TagData['genre'][] = '90s Classics';
$tagwriter->tag_data = $TagData;
if ($tagwriter->WriteTags()) {
echo 'success';
} else {
echo 'failure';
}
我总是感到"失败"。getid3_writetags
函数的路径很好。我知道这一点是因为当我print_r($tagwriter);
时,它会按指定输出所有数组。但是,"warnings"one_answers"errors"数组都为空。
此外,当我执行以下操作时,它成功地返回了所有正确的标签信息:
$data = $getid3->analyze( $testfile );
print_r($data)
我还应该注意到,当我运行演示中包含的demo.write.php
时,它也会失败。它会一直到starting to write tag(s)
,然后停止。
有什么想法吗?我会在getid3.org论坛上发帖,但我的IP被列入黑名单(
Wordpress在实现时并没有包含整个GetID3库。他们只使用这些文件来获取最流行的视频和音频标签。