问题来自这个方法:
public void playSound(String pathSound) {
Log.i("Playsound pathFile", "Path:"+pathSound);
if(mp != null)
{
mp.stop();
mp.release();
mp = null;
}
mp = new MediaPlayer();
try{
mp.setDataSource(pathSound);
mp.prepare();
}catch(Exception e){
Log.i("PLAY SOUND ERROR",e.toString());
}
mp.start();
}
在我的应用程序中,我在运行时下载声音文件,并将 pathFiles 存储在 SQLite 中,然后我可以使用它。
声音文件的路径是:
PathSound="/data/data/com.example.mypackage/Folder/Raws/title.mp3",不知道有没有权限把这个文件放在这里。
给我的错误:
06-04 15:26:18.420: E/MediaPlayer(1043): error (1, -2147483648)
06-04 15:26:18.420: W/System.err(1043): java.io.IOException: Prepare failed.: status=0x1
06-04 15:26:18.430: W/System.err(1043): at android.media.MediaPlayer.prepare(Native Method)
06-04 15:26:18.430: W/System.err(1043): at com.example.databasesqlitetest.ItemActivity.playSound(ItemActivity.java:187)
06-04 15:26:18.439: W/System.err(1043): at com.example.databasesqlitetest.ItemActivity$2.onClick(ItemActivity.java:91)
06-04 15:26:18.439: W/System.err(1043): at android.view.View.performClick(View.java:3540)
06-04 15:26:18.449: W/System.err(1043): at android.view.View$PerformClick.run(View.java:14167)
06-04 15:26:18.449: W/System.err(1043): at android.os.Handler.handleCallback(Handler.java:605)
06-04 15:26:18.459: W/System.err(1043): at android.os.Handler.dispatchMessage(Handler.java:92)
06-04 15:26:18.459: W/System.err(1043): at android.os.Looper.loop(Looper.java:137)
06-04 15:26:18.459: W/System.err(1043): at android.app.ActivityThread.main(ActivityThread.java:4560)
06-04 15:26:18.459: W/System.err(1043): at java.lang.reflect.Method.invokeNative(Native Method)
06-04 15:26:18.459: W/System.err(1043): at java.lang.reflect.Method.invoke(Method.java:511)
06-04 15:26:18.469: W/System.err(1043): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-04 15:26:18.469: W/System.err(1043): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-04 15:26:18.469: W/System.err(1043): at dalvik.system.NativeStart.main(Native Method)
06-04 15:26:18.469: E/MediaPlayer(1043): start called in state 0
06-04 15:26:18.469: E/MediaPlayer(1043): error (-38, 0)
06-04 15:26:18.479: E/MediaPlayer(1043): Error (-38,0)