2013-08-16 45 views
0

我試圖利用Wordpress的3.6支持getID3(),但是我無法將ID3標籤寫入我的mp3。這裏是我使用的代碼:無法使用getID3編寫ID3標籤1.9.7

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);,它輸出指定的所有陣列。然而'警告'和'錯誤'數組都是空的。

而且,當我做成功之後返回所有正確的標籤信息:

$data = $getid3->analyze($testfile); 
print_r($data) 

我也應該注意到,包括在演示中demo.write.php當我運行它也會失敗。然後它就會停止,直到starting to write tag(s)

任何想法?我會在getid3.org論壇發帖,但我的IP被列入黑名單。 :(

回答

1

Wordpress在實現它時並未包含整個GetID3庫,它們只使用這些文件來獲得最流行的視頻和音頻標籤