This commit is contained in:
walzer 2011-04-07 16:57:58 +08:00
commit 0173d0c3b7
2 changed files with 20 additions and 8 deletions

View File

@ -39,6 +39,7 @@ public class Cocos2dxMusic {
try {
mBackgroundMediaPlayer.prepare();
mBackgroundMediaPlayer.seekTo(0);
mBackgroundMediaPlayer.start();
} catch (Exception e){
Log.e(TAG, "playBackgroundMusic: error state");
@ -49,6 +50,10 @@ public class Cocos2dxMusic {
public void stopBackgroundMusic(){
if (mBackgroundMediaPlayer != null){
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 {
mBackgroundMediaPlayer.prepare();
mBackgroundMediaPlayer.seekTo(0);
mBackgroundMediaPlayer.start();
} catch (Exception e){
Log.e(TAG, "rewindBackgroundMusic: error state");
@ -116,8 +122,8 @@ public class Cocos2dxMusic {
}
private void initData(){
mLeftVolume =1.0f;
mRightVolume = 1.0f;
mLeftVolume =0.5f;
mRightVolume = 0.5f;
mBackgroundMediaPlayer = null;
mIsPaused = false;
}

View File

@ -39,6 +39,7 @@ public class Cocos2dxMusic {
try {
mBackgroundMediaPlayer.prepare();
mBackgroundMediaPlayer.seekTo(0);
mBackgroundMediaPlayer.start();
} catch (Exception e){
Log.e(TAG, "playBackgroundMusic: error state");
@ -49,6 +50,10 @@ public class Cocos2dxMusic {
public void stopBackgroundMusic(){
if (mBackgroundMediaPlayer != null){
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 {
mBackgroundMediaPlayer.prepare();
mBackgroundMediaPlayer.seekTo(0);
mBackgroundMediaPlayer.start();
} catch (Exception e){
Log.e(TAG, "rewindBackgroundMusic: error state");
@ -116,8 +122,8 @@ public class Cocos2dxMusic {
}
private void initData(){
mLeftVolume =1.0f;
mRightVolume = 1.0f;
mLeftVolume =0.5f;
mRightVolume = 0.5f;
mBackgroundMediaPlayer = null;
mIsPaused = false;
}