本文整理汇总了Java中org.andengine.audio.music.Music类的典型用法代码示例。如果您正苦于以下问题:Java Music类的具体用法?Java Music怎么用?Java Music使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Music类属于org.andengine.audio.music包,在下文中一共展示了Music类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: playLevelSound
import org.andengine.audio.music.Music; //导入依赖的package包/类
/**
* Play the given audio file
* @param soundFile
*/
public void playLevelSound(String soundFile, MediaPlayer.OnCompletionListener callback) {
Debug.d("Playing sound: "+soundFile);
if (!this.isStarted || !this.isRunning) {
Debug.d("Game hasn't started yet, not playing any sound");
return;
}
if (this.levelSounds.containsKey(soundFile)) {
Music sound = this.levelSounds.get(soundFile);
sound.setOnCompletionListener(callback);
sound.play();
} else {
Debug.d("No levelSounds: " + soundFile + "");
}
}
示例2: playMusic
import org.andengine.audio.music.Music; //导入依赖的package包/类
public void playMusic(Music music) {
if (this.mMusic != null) {
this.mMusic.stop();
}
this.mMusic = music;
this.mMusic.play();
}
示例3: getInstance
import org.andengine.audio.music.Music; //导入依赖的package包/类
public static MediaManager getInstance(BaseGameActivity pBaseActivity) {
if (self == null) {
self = new MediaManager();
MediaManager.mBaseActivity = pBaseActivity;
MediaManager.mMusicArray = new SparseArray<Music>();
MediaManager.mSoundArray = new SparseArray<Sound>();
}
return self;
}
示例4: play
import org.andengine.audio.music.Music; //导入依赖的package包/类
public void play(MusicType pMusicType, boolean isStart) {
Music music = get(pMusicType);
// 再生中
if (music.isPlaying()) {
return;
}
stopPlayingMusic(); // 再生中のBGMは全部止めてから再生する
// 再生する(基本ループ)
music.setLooping(true);
music.play();
}
示例5: pause
import org.andengine.audio.music.Music; //导入依赖的package包/类
public void pause(MusicType pMusicType) {
Music music = get(pMusicType);
// 再生中
if (music.isPlaying()) {
// 一時停止
music.pause();
}
}
示例6: pausePlayingMusic
import org.andengine.audio.music.Music; //导入依赖的package包/类
public void pausePlayingMusic() {
int size = mMusicArray.size();
for (int i = 0; i < size; i++) {
MusicType musicType = MusicType.get(mMusicArray.keyAt(i));
Music music = get(musicType);
if (music.isPlaying()) {
music.pause();
mPauseMusicType = musicType;
}
}
}
示例7: get
import org.andengine.audio.music.Music; //导入依赖的package包/类
private Music get(MusicType pMusicType) {
Music music = mMusicArray.get(pMusicType.getValue());
// 未生成, 解放済み
if (music == null) {
throw new RuntimeException("not create musicType = " + pMusicType);
}
if (music.isReleased()) {
throw new RuntimeException("released musicType = " + pMusicType);
}
return music;
}
示例8: playMusic
import org.andengine.audio.music.Music; //导入依赖的package包/类
/**
* Begins playing music.
* @param m
*/
public static void playMusic(Music m) {
if(m != null && !m.isPlaying()) {
m.setVolume(getMusicVolume());
m.play();
}
}
示例9: playMusicLoop
import org.andengine.audio.music.Music; //导入依赖的package包/类
/**
* Play music in looping.
* @param m
*/
public static void playMusicLoop(Music m) {
if(m != null && !m.isPlaying()) {
m.setVolume(getMusicVolume());
m.setLooping(true);
m.play();
}
}
示例10: stopMusic
import org.andengine.audio.music.Music; //导入依赖的package包/类
/**
* Stops music and sets the tune to the begining.
* @param m
*/
public static void stopMusic(Music m) {
if(m != null && m.isPlaying()) {
m.pause();
m.seekTo(0);
}
}
示例11: isPlaying
import org.andengine.audio.music.Music; //导入依赖的package包/类
public static boolean isPlaying(Music m) {
return m.isPlaying();
}
示例12: pauseMusic
import org.andengine.audio.music.Music; //导入依赖的package包/类
/**
* Pause music. May be resumed.
* @param m
*/
public static void pauseMusic(Music m) {
if(m != null && m.isPlaying())
m.pause();
}
示例13: resumeMusic
import org.andengine.audio.music.Music; //导入依赖的package包/类
/**
* Resume Music (works with pauseMusic).
* @param m
*/
public static void resumeMusic(Music m) {
m.setVolume(getMusicVolume());
m.resume();
}
示例14: playMusic
import org.andengine.audio.music.Music; //导入依赖的package包/类
private void playMusic(Music music) {
if (music != null && !music.isReleased()) {
music.play();
}
}