protected MediaPlayer _mediaPlayer;
protected void playFromResource(int resId)
{
if (_mediaPlayer != null)
{
_mediaPlayer.stop();
_mediaPlayer.release();
}
_mediaPlayer = MediaPlayer.create(this, resId);
_mediaPlayer.start();
}
This code used to work fine on both the emulator and on devices. Since some time (I think it is since I updated to ADT r10) it only works on devices. On the emulator there is no sound anymore and the application freezes when it pass on _mediaPlayer.release()
(the second time the function is called). I was able to keep the application from crashing by replacing the stop()
and release()
by reset()
but it does not solve the main issue: There is no sound on the emulator.
the log file show me a bunch of these (only on the emulator) just after the call to start()
03-09 19:14:30.716: WARN/AudioTrack(34): obtainBuffer timed out (is
the CPU pegged?) 0x1afb8 user=00001e00, server=00000600
Any clues ????
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…