问题
Occasionally when I have a lot going on in my app, and I am playing a number of sounds using SoundPool, my app just completely freezes. Looking at the logs, I see this: I/AudioHardwareMSM72XX( 56): AudioHardware pcm playback is going to standby.
My app must then be force closed and restarted. Does anyone know what may be causing this, or a possible workaround? I cannot reproduce this in the emulator - only on my HTC Hero, so I am wondering if this may be a device specific bug.
回答1:
There are two possible causes of this.
Cause 1: If you don't keep hold of a reference to your MediaPlayer object it can get garbage collected even though it is playing something. I have some code in a repeating timer that plays a sound, I had to assign the MediaPlayer to a static variable to stop it being garbage collected, and the problem of the sound stopping part way through went away.
Cause 2: I've read that if you are streaming it is possible to give the MediaPlayer too much data and it dies - see this discussion thread: /593575">http://www.last.fm/group/Last.fm+Android/forum/114391//593575
来源:https://stackoverflow.com/questions/3047817/android-audiohardware-pcm-playback-is-going-to-standby