preloadBackgroundMusic and unloadBackgroundMusic

Hi, I have added preloadBackgroundMusic and unloadBackgroundMusic to android-port

You can check the attached files see if it can add into repository or not. :slight_smile:

I also changed prepare/stop to pause/seekTo in order to prevent a little lag(I/O time) when loading BGM.


SimpleAudioEngineJni.h.zip (0.5 KB)


Cocos2dxActivity.java.zip (2.6 KB)


Cocos2dxMusic.java.zip (1.5 KB)


SimpleAudioEngine.h.zip (1.9 KB)


SimpleAudioEngine.cpp.zip (1.3 KB)


SimpleAudioEngineJni.cpp.zip (1.5 KB)

Thanks a lot! Feature #687 create. I’m very certain that these code will be merge can publish in the next minor version.

playBackgroundMusic() is quick in android, so I don’t implement it.
unloadBackgroundMusic, it is not included in cocos2d-iphone too. I don’t think we need this method.

On my acer liquid or other old android devices, it’s slow when run MediaPlayer.prepare(). So I modified playBackgroundMusic.
And android only have a few memory to use so I think it’s necessary to have unloadBackgroundMusic on android.

Ok, I will add the implmentation of preloadBackgroundMusic.
And android only have a few memory to use so I think it’s necessary to have unloadBackgroundMusic on android.
you can use end() to reinit the simple audio engine.