我正在尝试利用 Wordpress 对 getID3() 的 3.6 支持,但在将 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
函数的路径很好。我知道这一点,因为当 I 时print_r($tagwriter);
,它会按指定输出所有数组。然而,“警告”和“错误”数组都是空的。
此外,当我执行以下操作时,它成功返回所有正确的标签信息:
$data = $getid3->analyze( $testfile );
print_r($data)
我还应该注意,demo.write.php
当我运行它时,演示中包含的内容也会失败。它一直到starting to write tag(s)
然后停止。
有任何想法吗?我会在 getid3.org 论坛上发帖,但我的 IP 被列入黑名单。:(