2011-06-30 57 views
1

我試圖從SD卡播放WAV文件。它適用於某些手機(Nexus S,Nexus One等),但不適用於Xperia Mini系列。WAV文件MediaPlayer

代碼:

// On some phones, this line works, but on Xperia Mini 
// series phones MediaPlayer.create() 
// returns null from this line below. 
MediaPlayer mp = MediaPlayer.create(this, Uri.fromFile(new File(filePath))); 

The LogCat error message can be found here

任何想法?它肯定適用於某些手機,但其他手機只會拒絕wav文件。

回答

1

好像是同一個問題(和解決方案),因爲這一個: Android - play sound on button click - Null pointer exception

+0

的問題是有點不同。我甚至無法在MediaPlayer對象上調用mp.start(),當我這樣做時,它會給我一個NPE。 – Curtain

+0

Gah!愚蠢的我!我自己錄製的wav文件格式錯誤。感謝您的貢獻! – Curtain