mirror of https://github.com/axmolengine/axmol.git
Merge pull request #9088 from Dhilan007/v3-audio-Lollipop
Fix SimpleAudioEngine::sharedEngine()->playBackgroundMusic() freeze on Lollipop
This commit is contained in:
commit
ee31273fa5
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue