I\'ve been really banging my head against the table trying to get the MediaPlayer class to try to play h.264-encoded videos on Android 2.1. My code is rather simple:
<If anyone else gets stuck on this when reading from a remote URL,
my urls were all nonsecure, (i.e. http instead of https)
since I had no access to the server urls (3rd party)
I had to add the following in the android manifest.
<application
...
android:usesCleartextTraffic="true"
...
</application>
I know that I am late here but hopefully this helps somebody else. I worked around this issue by setting up a setOnCompletionListener
callback that explicitly releases the MediaPlayer object after the media is done playing.
I can't take credit for this solution, as it was originally posted by Ronny here: How do you detect when a sound file has finished?
But since this is the first answer when I search for Android+Failed Status 0x1 here is my code that solved this problem for me:
public void playSound(String soundPath){
MediaPlayer m = new MediaPlayer();
m.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
mp.release();
}
});
try {
AssetFileDescriptor descriptor = mContext.getAssets().openFd(soundPath);
m.setDataSource(descriptor.getFileDescriptor(), descriptor.getStartOffset(),
descriptor.getLength());
descriptor.close();
m.prepare();
m.setVolume(100f, 100f);
m.setLooping(false);
m.start();
} catch (Exception e) {
//Your catch code here.
}
}
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/