mirror of https://github.com/axmolengine/axmol.git
Merge branch 'master' of https://github.com/minggo/cocos2d-x
This commit is contained in:
commit
0173d0c3b7
|
@ -39,6 +39,7 @@ public class Cocos2dxMusic {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mBackgroundMediaPlayer.prepare();
|
mBackgroundMediaPlayer.prepare();
|
||||||
|
mBackgroundMediaPlayer.seekTo(0);
|
||||||
mBackgroundMediaPlayer.start();
|
mBackgroundMediaPlayer.start();
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
Log.e(TAG, "playBackgroundMusic: error state");
|
Log.e(TAG, "playBackgroundMusic: error state");
|
||||||
|
@ -49,6 +50,10 @@ public class Cocos2dxMusic {
|
||||||
public void stopBackgroundMusic(){
|
public void stopBackgroundMusic(){
|
||||||
if (mBackgroundMediaPlayer != null){
|
if (mBackgroundMediaPlayer != null){
|
||||||
mBackgroundMediaPlayer.stop();
|
mBackgroundMediaPlayer.stop();
|
||||||
|
|
||||||
|
// should set the state, if not , the following sequence will be error
|
||||||
|
// play -> pause -> stop -> resume
|
||||||
|
this.mIsPaused = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,6 +76,7 @@ public class Cocos2dxMusic {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mBackgroundMediaPlayer.prepare();
|
mBackgroundMediaPlayer.prepare();
|
||||||
|
mBackgroundMediaPlayer.seekTo(0);
|
||||||
mBackgroundMediaPlayer.start();
|
mBackgroundMediaPlayer.start();
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
Log.e(TAG, "rewindBackgroundMusic: error state");
|
Log.e(TAG, "rewindBackgroundMusic: error state");
|
||||||
|
@ -116,8 +122,8 @@ public class Cocos2dxMusic {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initData(){
|
private void initData(){
|
||||||
mLeftVolume =1.0f;
|
mLeftVolume =0.5f;
|
||||||
mRightVolume = 1.0f;
|
mRightVolume = 0.5f;
|
||||||
mBackgroundMediaPlayer = null;
|
mBackgroundMediaPlayer = null;
|
||||||
mIsPaused = false;
|
mIsPaused = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ public class Cocos2dxMusic {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mBackgroundMediaPlayer.prepare();
|
mBackgroundMediaPlayer.prepare();
|
||||||
|
mBackgroundMediaPlayer.seekTo(0);
|
||||||
mBackgroundMediaPlayer.start();
|
mBackgroundMediaPlayer.start();
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
Log.e(TAG, "playBackgroundMusic: error state");
|
Log.e(TAG, "playBackgroundMusic: error state");
|
||||||
|
@ -49,6 +50,10 @@ public class Cocos2dxMusic {
|
||||||
public void stopBackgroundMusic(){
|
public void stopBackgroundMusic(){
|
||||||
if (mBackgroundMediaPlayer != null){
|
if (mBackgroundMediaPlayer != null){
|
||||||
mBackgroundMediaPlayer.stop();
|
mBackgroundMediaPlayer.stop();
|
||||||
|
|
||||||
|
// should set the state, if not , the following sequence will be error
|
||||||
|
// play -> pause -> stop -> resume
|
||||||
|
this.mIsPaused = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,6 +76,7 @@ public class Cocos2dxMusic {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mBackgroundMediaPlayer.prepare();
|
mBackgroundMediaPlayer.prepare();
|
||||||
|
mBackgroundMediaPlayer.seekTo(0);
|
||||||
mBackgroundMediaPlayer.start();
|
mBackgroundMediaPlayer.start();
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
Log.e(TAG, "rewindBackgroundMusic: error state");
|
Log.e(TAG, "rewindBackgroundMusic: error state");
|
||||||
|
@ -116,8 +122,8 @@ public class Cocos2dxMusic {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initData(){
|
private void initData(){
|
||||||
mLeftVolume =1.0f;
|
mLeftVolume =0.5f;
|
||||||
mRightVolume = 1.0f;
|
mRightVolume = 0.5f;
|
||||||
mBackgroundMediaPlayer = null;
|
mBackgroundMediaPlayer = null;
|
||||||
mIsPaused = false;
|
mIsPaused = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue