Audiotrack随机停止声音,但状态为STATE_INITIALIZED和PLAYSTATE_PLAYING

时间:2013-09-20 17:46:43

标签: android loops audiotrack

我正在循环和录音带......

audioTrack.setLoopPoints(0, length, -1);
audioTrack.play();

但是在随机时间(几分钟)之后,它会停止发声,但状态为STATE_INITIALIZED和PLAYSTATE_PLAYING。 在那一刻,我收到了这条消息......

09-20 19:32:27.989: D/audio_hw_primary(176): out_standby: enter: usecase(1: low-latency_playback)
09-20 19:32:28.039: D/audio_hw_primary(176): stop_output_stream: enter: usecase(1: low-    latency-playback)
09-20 19:32:28.049: D/audio_hw_primary(176): disable_audio_route: reset mixer path: low-latency-playback
09-20 19:32:28.049: D/audio_hw_primary(176): disable_snd_device: snd_device(2: speaker)
09-20 19:32:28.049: D/audio_hw_primary(176): stop_output_stream: exit: status(0)
09-20 19:32:28.049: D/audio_hw_primary(176): out_standby: exit

我需要无限循环audiotrack,拜托,有谁知道如何解决它?

PD:停止似乎只发生在4.1及更高版本中。

1 个答案:

答案 0 :(得分:0)

似乎电话正在进入待机状态,当您配置MediaPlayer时,您是否获得了唤醒锁?

yourMediaPlayer.setWakeMode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK);

不要忘记稍后释放你的mplayer。