简体   繁体   English

在单独的线程中播放短声音

[英]Playing short sounds in separate thread

In my android game, there are 36 falling balls. 在我的Android游戏中,有36个落球。 When a ball touches the ground a sound is played. 当球触地时,会发出声音。 The sound is very small, only 0.3 sec. 声音很小,只有0.3秒。 I am using soundpool class to play it. 我正在使用soundpool类进行播放。 It may happen in the game that all 36 balls fall in quick succession. 在游戏中可能会发生所有36个球快速连续掉落的情况。 Playing the sound so many times may block the UI thread. 多次播放声音可能会阻塞UI线程。 Is it advisable to play sound on separate thread ? 建议在单独的线程上播放声音吗?

Yes! 是! You should play the sound on aa separate thread. 您应该在一个单独的线程上播放声音。 Check the solution provided to a similar question here 此处检查提供给类似问题的解决方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM