Search in sources :

Example 6 with Music

use of com.badlogic.gdx.audio.Music in project Catacomb-Snatch by Catacomb-Snatch.

the class GdxSoundPlayer method loadMusic.

private void loadMusic(Sounds music) {
    try {
        Gdx.app.log(TAG, Gdx.files.internal("music/" + music.name + ".ogg").file().getAbsolutePath());
        Music file = Gdx.audio.newMusic(Gdx.files.internal("music/" + music.name + ".ogg"));
        // If background track, add to playlist
        if (music.name.toLowerCase().startsWith("background"))
            backgroundMusicList.add(file);
        musicMap.put(music.name, file);
    } catch (GdxRuntimeException e) {
        Gdx.app.log(TAG, "Error loading musicfile: " + music.name + ": " + e.getMessage());
    }
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException) Music(com.badlogic.gdx.audio.Music)

Example 7 with Music

use of com.badlogic.gdx.audio.Music in project libgdx by libgdx.

the class MusicLoader method loadSync.

@Override
public Music loadSync(AssetManager manager, String fileName, FileHandle file, MusicParameter parameter) {
    Music music = this.music;
    this.music = null;
    return music;
}
Also used : Music(com.badlogic.gdx.audio.Music)

Example 8 with Music

use of com.badlogic.gdx.audio.Music in project libgdx by libgdx.

the class ExternalMusicTest method create.

@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();
}
Also used : FileHandle(com.badlogic.gdx.files.FileHandle) Music(com.badlogic.gdx.audio.Music)

Example 9 with Music

use of com.badlogic.gdx.audio.Music in project ultimate-java by pantinor.

the class Sounds method play.

public static Music play(Sound sound, OnCompletionListener ocl) {
    Music m = sounds.get(sound);
    if (m == null) {
        m = Gdx.audio.newMusic(Gdx.files.internal("assets/sound/" + sound.getFile()));
        m.setVolume(sound.getVolume());
        m.setLooping(sound.getLooping());
        sounds.put(sound, m);
    }
    m.setOnCompletionListener(ocl);
    m.play();
    return m;
}
Also used : Music(com.badlogic.gdx.audio.Music)

Example 10 with Music

use of com.badlogic.gdx.audio.Music in project Catacomb-Snatch by Catacomb-Snatch.

the class GdxSoundPlayer method stopTitleMusic.

@Override
public void stopTitleMusic() {
    Music titleMusic = getMusic(Sounds.TITLE_THEME);
    if (titleMusic == null) {
        return;
    }
    if (titleMusic.isPlaying()) {
        titleMusic.stop();
    }
    TitleIsPlaying = false;
}
Also used : Music(com.badlogic.gdx.audio.Music)

Aggregations

Music (com.badlogic.gdx.audio.Music)14 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)2 OnCompletionListener (com.badlogic.gdx.audio.Music.OnCompletionListener)1 Sound (com.badlogic.gdx.audio.Sound)1 FileHandle (com.badlogic.gdx.files.FileHandle)1