Android MediaPlayer prepare failed: status = 0x1

北战南征 提交于 2019-12-01 16:02:15

I figured it out: Stupid mistakes as usual. I forgot to add the read external memory permission, and I have Vasily to thank for that fix because of your comment above. The other thing was that I didn't call getText() on my date TextView so it didn't properly set the file name.

Ganesh

I think you are facing the issue due to an incorrect DataSource being set to your MediaPlayer. Can you please try your setDataSource with the following change

mediaPlayer.setDataSource("file://sdcard/test/"
             + date.toString() + ".3gp");

I think with this change, your code should work fine

EDIT: Please check this post MediaPlayer Preparing Failed for more details on the reason behind prefixing file:// to your file name.

I hope following code will help:

String soundPath = Environment.getExternalStorageDirectory().getPath() + "test/" + date.toString() + ".mp3";
mediaPlayer.setDataSource(soundPath);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!