Android MediaPlayer throwing "Prepare failed.: status=0x1" on 2.1, works on 2.2
This is my solution:
MediaPlayer mediaPlayer = new MediaPlayer();
FileInputStream fis = null;
try {
File directory = new File("android.resource://com.example.myapp/raw/");
fis = new FileInputStream(directory);
mediaPlayer.setDataSource(fis.getFD());
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.prepare();
} finally {
if (fis != null) {
try {
fis.close();
} catch (IOException ignore) {
}
}
}
I do not know if this is your issue, but I just found a solution to the problem the described by Tuszy above. I could read the file I was creating from external storage but not from Cache.
The solution is that the read write permissions when writing the file are different.
Please see this excellent explanation in this blog I found.
http://blog.weston-fl.com/android-mediaplayer-prepare-throws-status0x1-error1-2147483648/