2011-05-10 34 views
1

我正在嘗試使用此class來提取預覽的前30秒。這裏是我的代碼我使用類錯了嗎?

include("class.mp3.php"); 
$file_input = "hat.mp3"; 
$file_output = "output.mp3"; 
$mp3 = new mp3($file_input); 
$mp3_1 = $mp3->cut_mp3($file_input, $file_output, 0, 30); 

hat.mp3是在同一目錄下,我期待看到output.mp3爲30秒的剪輯...任何想法我在做什麼錯的,如果有一個更簡單,更好的庫用於這種情況....

+0

你在做什麼呢? – 2011-05-10 11:45:14

+0

只是一個空白的屏幕... – Trace 2011-05-10 12:25:28

回答

2

cut_mp3功能和其他功能get_mp3等使用 '@' 符:

if(!$fp = @fopen($file_output, 'wb')) { 
    return false; 
} 

而且你不會看到任何錯誤消息。首先檢查目錄的權限。

+0

你是什麼意思@運營商....你的意思像@ cut_mp3在這個$ mp3_1 = $ mp3 - > @ cut_mp3($ file_input,$ file_output,0,30); – Trace 2011-05-10 12:26:27

+0

是的,用這個操作符你不會看到任何錯誤信息。因此,您應該手動檢查權限。 – 2011-05-10 12:38:06

1

Web服務器需要爲您要輸出MP3的目錄有寫權限。不幸的是,該類似乎沒有任何錯誤處理,因爲它無法寫出輸出MP3。