@Override public void create () { // copy an internal mp3 to the external storage FileHandle src = Gdx.files.internal("data/8.12.mp3"); FileHandle dst = Gdx.files.external("8.12.mp3"); src.copyTo(dst); // create a music instance and start playback Music music = Gdx.audio.newMusic(dst); music.play(); }
void setSong (Song song) { if (music != null) { music.dispose(); } switch (song) { default: case MP3: music = Gdx.audio.newMusic(Gdx.files.internal("data/8.12.mp3")); songDuration = 183; break; case OGG: music = Gdx.audio.newMusic(Gdx.files.internal("data/cloudconnected.ogg")); songDuration = 22; break; case WAV: music = Gdx.audio.newMusic(Gdx.files.internal("data/8.12.loop.wav")); songDuration = 4; break; } music.setLooping(btLoop.isChecked()); music.play(); }
@Override public void render () { currentPosition = music.getPosition(); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); batch.begin(); batch.draw(buttons, 0, 0); font.draw(batch, (int)currentPosition / 60 + ":" + (int)currentPosition % 60, 365, 35); batch.end(); sliderUpdating = true; slider.setValue((currentPosition / songDuration) * 100f); sliderUpdating = false; stage.act(); stage.draw(); if (Gdx.input.justTouched()) { if (Gdx.input.getY() > Gdx.graphics.getHeight() - 64) { if (Gdx.input.getX() < 64) { music.play(); } if (Gdx.input.getX() > 64 && Gdx.input.getX() < 128) { music.stop(); } if (Gdx.input.getX() > 128 && Gdx.input.getX() < 192) { music.pause(); } } } }
public void resume() { if (voice != null && isPaused) { voice.play(); isPaused = false; } }
public void resumeMusic() { if (music != null && isPaused) { music.play(); isPaused = false; } }
public void resume() { if (player != null) { player.play(); } }
public void play() { if (!loaded) { playOnLoad = true; } if (music == null || music.isPlaying()) { return; } music.play(); }
public void play() { if (currentMusic != null && !currentMusic.isPlaying()) { currentMusic.play(); } }
public void playMusic() { if (currentMusic.isEmpty()) { return; } Music music = assetManager.get(musicPath + currentMusic, Music.class); music.play(); }
/**播放一个音乐,如果正在播的就是这首音乐,则重新播放*/ public MusicProxy play(String path) { MusicProxy proxy = null; if(manager.containsKey(path)){ proxy = manager.get(path); }else{ proxy = new MusicProxy(Gdx.audio.newMusic(Gdx.files.internal(path))); manager.put(path, proxy); } proxy.music.play(); return proxy; }
private void initMusic(Music mus) { mus.setLooping(true); mus.setVolume(0.0f); mus.play(); }
public void resume() { var3dListener.onIOSResume(); if (isMusic != false && music != null) music.play(); if (stage != null && isLoading) stage.resume(); }
private void fadeInNextTrack() { float trackTargetVolume = MathUtils.clamp(((cursor - crossfadeTime) / crossfadeDuration), 0f, targetVolume); nextTrack.setVolume(trackTargetVolume); if (!nextTrack.isPlaying() && playing) { nextTrack.play(); } }
public void playPauseToggle() { if (currentMusic != null) { if (currentMusic.isPlaying()) { currentMusic.pause(); } else { currentMusic.play(); } } else { start(); } }
public TitleScreen() { if (DrunkToss.prefs.getBoolean("music") == false) { SoundLib.muteMusic = true; SoundLib.muteMusic(); } SoundLib.menuMusic.play(); SoundLib.menuMusic.setLooping(true); }
@Override public void run() { music = Gdx.audio.newMusic(EngineAssetManager.getInstance().getAsset(style.musicFile)); music.setLooping(true); music.play(); } }.start();
@Override public void run() { music = Gdx.audio.newMusic(EngineAssetManager.getInstance().getAsset(sound)); try { music.play(); } catch(Exception e) { // sometimes the play method fails on desktop. EngineLogger.error("Error Playing music: " + s, e); } } }.start();
void playSong(int songIdx) { Music song = songs.get(currentSongIdx); song.setOnCompletionListener(null); song.stop(); currentSongIdx = songIdx; song = songs.get(currentSongIdx); song.play(); song.setVolume(volume); song.setOnCompletionListener(listener); }
@Override public void create () { batch = new SpriteBatch(); gsm = new GameStateManager(); music = Gdx.audio.newMusic(Gdx.files.internal("music.mp3")); music.setLooping(true); music.setVolume(0.1f); music.play(); Gdx.gl.glClearColor(1, 0, 0, 1); gsm.push(new MenuState(gsm)); }