I have an inexplicable problem using MediaPlayer class in Android 4.4 KitKat. In my activity, I implement Google Play Services locationlistener. Evertyme location is changed, I call a function with this statements:
Resources res1 = ctext.getResources();
int soundId1 = res1.getIdentifier("ik", "raw",
ctext.getPackageName());
Resources res2 = ctext.getResources();
int soundId2 = res2.getIdentifier(prefix, "raw", ctext.getPackageName());
myMediaPlayer = MediaPlayer.create(ctext, soundId1);
myMediaPlayerNode = MediaPlayer.create(ctext, soundId2);
myMediaPlayerNode.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer player) {
myMediaPlayerNode.stop();
// play next audio file
}
});
myMediaPlayer.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer player) {
myMediaPlayer.stop();
myMediaPlayerNode.start();
// play next audio file
}
});
myMediaPlayer.start();
This works fine on all devices, except on a Samsung Galaxy s5 with android 4.4 kitkat. When I call the method outside de onlocationchanged event, it works fine. Is there something wrong with the mediamanager in android 4.4?