我在Android 4.4 KitKat中使用MediaPlayer类时遇到了一个莫名其妙的问题。在我的活动中,我实施了Google Play服务locationlistener。 Evertyme位置已更改,我使用以下语句调用函数:
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();
这适用于所有设备,除了带有android 4.4 kitkat的三星Galaxy s5。当我在de onlocationchanged事件之外调用方法时,它工作正常。 android 4.4中的mediamanager有什么问题吗?