2

I'm using MediaPlayer to play online track.But i got the problem:

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;
}

While preparing the first track(after prepareAsync() before onPrepared()), I try to play the second track,ANR got when called mMediaPlayer.reset(), and change to call the mMediaPlayer.release() but still ANR. So how can i stop the MediaPlayer's preparing without ANR? Somebody help. Thanks!

ploere
  • 21
  • 2
  • What if you call `reset` and `release` from another thread (i.e. not the UI thread)? And of course catch any exceptions that might be thrown. – Michael May 10 '13 at 09:52
  • Thanks,but i can got your mean.I player track with MediaPlayer in a Service, and when the ANR happened(without exceptions) i start new thread to play(call reset and others), but still ANR without exceptions.What i did wrong ? Sorry for my poor english! – ploere May 13 '13 at 04:41

0 Answers0