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:
<
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.
}
}