2

我正在使用 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()之后),我尝试播放第二首曲目,调用mMediaPlayer.reset()时出现ANR,并更改为调用mMediaPlayer.release()但仍然ANR。那么如何在没有 ANR 的情况下阻止 MediaPlayer 的准备工作?有人帮忙。谢谢!

4

0 回答 0