Use OpenSL ES to play effect on Android¶
Why using OpenSL ES¶
Some developers reported that using the original android’s SoundPool to play effects will lead to crash on SAMSUNG S2 I9100, so we decide to use OpenSL ES to resolve this problem. Please note that because so far the original SoundPool only crashes on I9100, the implementation of OpenSLES will only take place of the original SoundPool on I9100.
How to use OpenSL ES in Cocos2d-x¶
Actually, you don't have to do anything. We will detect your device model when you first using SimpleAudioEngine. If you're running on the I9100, it will automatically switch to OpenSLES, otherwise it will use the original SoundPool to play effect.
- OpenSL ES is only available on SAMSUNG S2 I9100.
- The current version of implement has a limitation of the count of preloaded effects. That is, you can only preload 31 effects at most.
- The volume interface is available but there might be a problem when trying to control the volume. We found that some devices including I9100 don’t support OpenSLES perfectly, and we couldn't get the accurate range of volume.
- [2012-08-17] Developers need not to specify the Android platform. It will detect your device model and will only work on I9100.
- [2012-08-02] When an effect is played for more than twice in a short time, it will be stopped and restarted playing instead of playing at the same time.