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) {
|
if (this.mBackgroundMediaPlayer == null) {
|
||||||
Log.e(Cocos2dxMusic.TAG, "playBackgroundMusic: background media player is null");
|
Log.e(Cocos2dxMusic.TAG, "playBackgroundMusic: background media player is null");
|
||||||
} else {
|
} else {
|
||||||
// if the music is playing or paused, stop it
|
|
||||||
this.mBackgroundMediaPlayer.stop();
|
|
||||||
|
|
||||||
this.mBackgroundMediaPlayer.setLooping(isLoop);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.mBackgroundMediaPlayer.prepare();
|
// if the music is playing or paused, stop it
|
||||||
this.mBackgroundMediaPlayer.seekTo(0);
|
if (mPaused) {
|
||||||
|
mBackgroundMediaPlayer.seekTo(0);
|
||||||
this.mBackgroundMediaPlayer.start();
|
this.mBackgroundMediaPlayer.start();
|
||||||
|
} else if (mBackgroundMediaPlayer.isPlaying()) {
|
||||||
|
mBackgroundMediaPlayer.seekTo(0);
|
||||||
|
} else {
|
||||||
|
this.mBackgroundMediaPlayer.start();
|
||||||
|
}
|
||||||
|
this.mBackgroundMediaPlayer.setLooping(isLoop);
|
||||||
this.mPaused = false;
|
this.mPaused = false;
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
Log.e(Cocos2dxMusic.TAG, "playBackgroundMusic: error state");
|
Log.e(Cocos2dxMusic.TAG, "playBackgroundMusic: error state");
|
||||||
|
|
Loading…
Reference in New Issue