安卓的mediaplayer 不能实现播放?
btn_send_activity_play.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
String s = Environment.getExternalStorageDirectory().getAbsolutePath().toString()
+ "/netease/cloudmusic/Music";
s += "/sad.mp3";
Log.i("joursion",s);
File f = new File(s);
//检查是否存在
if(!f.exists()){
Log.i("joursion", "not exit");
}
else
Log.i("joursion", " exit");
mediaPlayer.reset();
mediaPlayer.setDataSource(s);
Log.i("joursion", " exit");
if (!mediaPlayer.isPlaying()) {
Log.i("joursion", "play");
mediaPlayer.prepare();
mediaPlayer.start();
} else {
mediaPlayer.pause();
}
} catch (IOException e) {
Log.e("joursion","play err");
}
}
});
这是权限
这是log日志,文件是存在的,但是 不能播放
戏言スピーカー
9 years, 4 months ago