MediaPlayer有问题。就在我设置数据源时,我得到错误:
02-22 21:26:10.050: E/MediaPlayer-JNI(7332): setDataSource: outside path in JNI is �x@
我的设备是Samsum Galaxy Advance和我的代码:
try {
mediaPlayer.reset();
mediaPlayer.setDataSource(audioFile);
mediaPlayer.prepare();
mediaController.show();
mediaPlayer.start();
} catch (IllegalArgumentException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (SecurityException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IllegalStateException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
答案 0 :(得分:0)
尝试像这样设置数据源路径并以这种方式使用mediacontroller:
String audioFile= Environment.getExternalStorageDirectory().getAbsolutePath();
audioFile+="/NaturaLocal/muralla_torreVieja_es.mp3";
MediaPlayer mp = new MediaPlayer();
MediaController mc= new MediaController(mp);
mc.setDataSource(audiofile);
mc.prepare();
mc.start();