Merge pull request #9088 from Dhilan007/v3-audio-Lollipop

Fix SimpleAudioEngine::sharedEngine()->playBackgroundMusic() freeze on Lollipop
This commit is contained in:
minggo 2014-11-13 16:02:40 +08:00
commit ee31273fa5
1 changed files with 10 additions and 9 deletions

View File

@ -112,16 +112,17 @@ public class Cocos2dxMusic {
if (this.mBackgroundMediaPlayer == null) {
Log.e(Cocos2dxMusic.TAG, "playBackgroundMusic: background media player is null");
} else {
// if the music is playing or paused, stop it
this.mBackgroundMediaPlayer.stop();
this.mBackgroundMediaPlayer.setLooping(isLoop);
try {
this.mBackgroundMediaPlayer.prepare();
this.mBackgroundMediaPlayer.seekTo(0);
this.mBackgroundMediaPlayer.start();
// if the music is playing or paused, stop it
if (mPaused) {
mBackgroundMediaPlayer.seekTo(0);
this.mBackgroundMediaPlayer.start();
} else if (mBackgroundMediaPlayer.isPlaying()) {
mBackgroundMediaPlayer.seekTo(0);
} else {
this.mBackgroundMediaPlayer.start();
}
this.mBackgroundMediaPlayer.setLooping(isLoop);
this.mPaused = false;
} catch (final Exception e) {
Log.e(Cocos2dxMusic.TAG, "playBackgroundMusic: error state");