Android Media Player Exceptions: Common Problem and Solutions

Problem: When using Android Media Player you get exception:

  1. java.io.IOException: Prepare failed.: status=0x1
  2. Java.io.exception: setDataSource error 0x800000

Common Solutions:

  1. Lot of people have said this is many times due to bad or corruptedĀ Mp3 ,OGG or other file.
  2. Another solution is MediaPlayer.setDataSource has 3 overloaded variants. but the one which works is the one which takes 3 parameters, FileDescriptor, start Offset and length. If you dont give all 3 you face this issue. A newbie is very likely to hit this.

 

Common ways to debug this:

  1. If you are using MediaPlayer.Create(XXX) variant then most likely the issue is bad corrputed file.
  2. Most people face issue#2 when they try to use setDataSource vriant. Keep in mind to use the right one.
  3. To debug issue whether MP3 is corrupted or not : try copying the MP3 to raw directory and then use MediaPlayer.Create(resource id) variant. If that fails then most probably issue is with the file. If that works then that confirms the quality of your file and you need to look at your code.

Hope this helps. I spent lot of time struggling with MediaPlayer issues. Let me know if you face any and I will try to help you as much as I can.

 

Be Sociable, Share!
This entry was posted in Android. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>