我正在使用MediaPlayer播放在线曲目。但我遇到了问题:
try {
mMediaPlayer.reset();
mMediaPlayer.setDataSource(path);
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mMediaPlayer.setOnPreparedListener(preparedlistener);
mMediaPlayer.prepareAsync();
} catch (IOException ex) {
log.e(TAG, "IOException in setDataSourceAsync : path = " + path);
} catch (IllegalArgumentException ex) {
log.e(TAG, "IllegalArgumentException in setDataSourceAsync : path = " + path);
return;
}
在准备第一首曲目时(在执行onPrepared()之前的prepareAsync()之后),我尝试播放第二首曲目,ANR在调用mMediaPlayer.reset()时获取,并更改为调用mMediaPlayer.release()但仍然是ANR 。 那么如何在没有ANR的情况下停止MediaPlayer的准备呢?有人帮忙。谢谢!