Java 类com.badlogic.gdx.audio.Music 实例源码

项目:ggvm    文件:SoundtrackManager.java   
/**
 * Plays a song without stopping any currently playing songs. This should only be used
 * when we know the current song is about to end, for seamless transitions between
 * introductions and looping portions of songs.
 * @param fileName
 * @param looping
 */
protected void playSongNoStop(final String fileName, final boolean looping) {
    loadSong(fileName);
    Music music = songs.get(fileName);
    currentSong = music;
    currentSongFileName = fileName;
    currentSong.setLooping(looping);
    currentSong.play();
}
项目:feup-lpoo-armadillo    文件:Sounds.java   
/**
 * Sounds constructor.
 * Plays the background music and initializes the game dependent sounds.
 *
 * @param assetManager Place where the sounds and musics are gotten from.
 */
public Sounds(AssetManager assetManager) {
    this.assetManager = assetManager;
    loadSounds();

    Music music = assetManager.get("music/Artofescapism_-_Three_Star_Sky.mp3");
    music.setVolume(0.5f);
    music.setLooping(true);
    music.play();

    //Initializing the game different sounds
    powerup = assetManager.get("music/item.mp3");
    jump = assetManager.get("music/jump.wav");
    lost = assetManager.get("music/lost.wav");
    won = assetManager.get("music/won.wav");
    water = assetManager.get("music/water.wav");
}
项目:SpaceChaos    文件:CreditsScreen.java   
@Override
protected void onInit(ScreenBasedGame game, AssetManager assetManager) {
    // load assets
    assetManager.load(MUSIC_PATH, Music.class);
    assetManager.load(BACKGROUND_IMAGE_PATH, Texture.class);
    assetManager.finishLoadingAsset(MUSIC_PATH);
    assetManager.finishLoadingAsset(BACKGROUND_IMAGE_PATH);

    // get assets
    this.music = assetManager.get(MUSIC_PATH, Music.class);
    this.bgTexture = assetManager.get(BACKGROUND_IMAGE_PATH, Texture.class);

    // generate fonts
    this.titleFont = BitmapFontFactory.createFont("./data/font/spartakus/SparTakus.ttf", 48, Color.WHITE,
            Color.BLUE, 3);
    // this.font2 =
    // BitmapFontFactory.createFont("./data/font/spartakus/SparTakus.ttf",
    // 48, Color.RED, Color.WHITE, 3);
    this.font1 = BitmapFontFactory.createFont("./data/font/arial/arial.ttf", 18, Color.WHITE);
    this.font2 = BitmapFontFactory.createFont("./data/font/arial/arial-bold.ttf", 24, Color.WHITE, Color.RED, 3);

    // generate credits text array
    try {
        this.generateCreditLines();
    } catch (IOException e) {
        e.printStackTrace();

        // TODO: remove this line and handle exception with exception window
        System.exit(0);
    }

    Gdx.input.setInputProcessor(null);
}
项目:Polymorph    文件:Polymorph.java   
private void loadAssets() {
    InternalFileHandleResolver fileHandler = new InternalFileHandleResolver();
    assetManager = new AssetManager(fileHandler);
    assetManager.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(fileHandler));

    assetManager.load(SKIN_PATH, Skin.class);
    assetManager.load(MASTER_PATH, TextureAtlas.class);
    assetManager.load(FONT_NORMAL_PATH, FreeTypeFontGenerator.class);
    assetManager.load(FONT_BOLD_PATH, FreeTypeFontGenerator.class);
    assetManager.load(MUSIC_PATH, Music.class);
    assetManager.load(MAIN_MENU_MUSIC_PATH, Music.class);
    assetManager.load(GOOD_PATH, Sound.class);
    assetManager.load(HALF_PATH, Sound.class);
    assetManager.load(BAD_PATH, Sound.class);
    assetManager.finishLoading();
}
项目:libGdx-xiyou    文件:Play.java   
public void initMusic() {
    Music music;
    switch (level) {
        case 0:        //第一关
            //初始化音乐
            music = MyGdxGame.assetManager.getMusic(Constant.LEVEL_0_BGM);
            music.setLooping(true);
            music.play();
            break;
        case 1:        //第二关
        case 2:        //第三关
        case 3:        //第四关
            music = MyGdxGame.assetManager.getMusic(Constant.LEVEL_1_BGM);
            music.setLooping(true);
            music.play();
            break;
        case 4:        //第五关背景音乐
            music = MyGdxGame.assetManager.getMusic(Constant.LEVEL_2_BGM);
            music.setLooping(true);
            music.play();
            break;
    }
}
项目:nomoore    文件:CutsceneStoneAge.java   
public CutsceneStoneAge(MyGdxGame myGdxGame) {
    this.myGdxGame = myGdxGame;
    batch = myGdxGame.batch;
    sr = myGdxGame.sr;
    viewport = myGdxGame.viewport;
    camera = myGdxGame.camera;
    font = myGdxGame.font;

    particles = new Particles();

    bg = new Sprite(new Texture("sprites/orange.png"));
    girl = new Sprite(new Texture("sprites/girl.png"));
    stone = new Sprite(new Texture("sprites/stein_angemalt.png"));
    hominideSitzend = new Sprite(new Texture("sprites/hominide_sitzend.png"));
    hominideDuckend = new Sprite(new Texture("sprites/hominide_duckend.png"));
    hominideStehend = new Sprite(new Texture("sprites/hominide_stehend.png"));

    assetManager = new AssetManager();
    assetManager.load("music/tusch.mp3", Sound.class);
    assetManager.load("music/5_steinzeit.mp3", Music.class);

    assetManager.finishLoading();

    tusch = assetManager.get("music/tusch.mp3", Sound.class);
    musicStoneAge = assetManager.get("music/5_steinzeit.mp3", Music.class);
}
项目:jewelthief    文件:LogoScreen.java   
public LogoScreen(SpriteBatch batch, ShapeRenderer shapeRenderer, FitViewport viewport, OrthographicCamera camera) {
    this.batch = batch;
    this.shapeRenderer = shapeRenderer;
    this.viewport = viewport;
    this.camera = camera;

    spriteThere = new Sprite(new Texture("there.png"));
    spriteFactory = new Sprite(new Texture("factory.png"));
    spriteLibGdxLogo = new Sprite(new Texture("libgdx.png"));

    AssetManager am = JewelThief.getInstance().getAssetManager();
    am.load("audio/sounds/keyboard.ogg", Sound.class);
    am.load("audio/sounds/keyboard_go_back.ogg", Sound.class);
    am.load("audio/sounds/re.ogg", Sound.class);
    am.load("audio/sounds/libgdx.ogg", Music.class);
    am.finishLoading();

    soundTypeTheRefactory = am.get("audio/sounds/keyboard.ogg", Sound.class);
    soundGoBackOnKeyboard = am.get("audio/sounds/keyboard_go_back.ogg", Sound.class);
    soundTypeRe = am.get("audio/sounds/re.ogg", Sound.class);
    musicLibGdxJingle = am.get("audio/sounds/libgdx.ogg", Music.class);

    resetAnimation();
}
项目:rbcgj-2016    文件:AssetManager.java   
public static void init() {

        assetManager.setLoader(TiledMap.class, new TmxMapLoader());

        for (Assets.Fonts font : Assets.Fonts.values()) {
            assetManager.load(font.getPath(), BitmapFont.class);
        }
        for (Assets.Textures texture : Assets.Textures.values()) {
            assetManager.load(texture.getPath(), Texture.class);
        }
        for (Assets.Maps map : Assets.Maps.values()) {
            assetManager.load(map.getPath(), TiledMap.class);
        }
        for (Assets.Musics music : Assets.Musics.values()) {
            assetManager.load(music.getPath(), Music.class);
        }
        for (Assets.Sounds sound : Assets.Sounds.values()) {
            assetManager.load(sound.getPath(), Sound.class);
        }
        assetManager.finishLoading();
    }
项目:EvilBunnyGod    文件:AudioManager.java   
public void playIntroTheme()
{
    if(currentMusic!=null)
        currentMusic.stop();
    currentMusic = intro_loop_intro;
    intro_loop_intro.setOnCompletionListener(new Music.OnCompletionListener() {
        @Override
        public void onCompletion(Music music) {
            currentMusic = intro_loop_main;
            currentMusic.setVolume(vol);
            currentMusic.play();
            currentMusic.setVolume(vol);
        }
    });
    currentMusic.setVolume(vol);
    currentMusic.play();
    currentMusic.setVolume(vol);
    nextMusic = currentMusic;
}
项目:EvilBunnyGod    文件:AudioManager.java   
public void playNext(){
    System.out.println("next sound");

    Music old = currentMusic;

    if(nextMusic == null){
        nextMusic = currentMusic;
    }
    if(nextMusic == currentMusic)
        return;

    currentMusic=nextMusic;
    currentMusic.setVolume(vol);
    currentMusic.play();
    currentMusic.setVolume(vol);

    old.stop();
    old = null;

}
项目:cll1-gdx    文件:LearningSession.java   
public void run() {
    if (challengeAudio != null && challengeAudio.isPlaying()) {
        challengeAudio.setOnCompletionListener(new OnCompletionListener() {
            @Override
            public void onCompletion(Music music) {
                music.setOnCompletionListener(null);
                stage.addAction(actionLoadNextChallengeQuick());
            }
        });
        return;
    }
    // 5-minute check
    if (totalElapsed > maxTime_secs) {
        log("=== SESSION TIME UP!");
        pausedStage.addAction(actionShowCompletedDialog());
        userPause();
        return;
    }
    loadNextChallenge();
}
项目:cll1-gdx    文件:LearningSession.java   
private void loadNewChallengeAudio(final String newActiveAudioFile) {
    Gdx.app.postRunnable(new Runnable() {
        public void run() {
            if (challengeAudio != null) {
                challengeAudio.stop();
            }
            if (activeAudioFile != null) {
                if (assets.isLoaded(activeAudioFile)) {
                    assets.unload(activeAudioFile);
                }
            }
            assets.load(newActiveAudioFile, Music.class);
            assets.finishLoadingAsset(newActiveAudioFile);
            challengeAudio = assets.get(newActiveAudioFile, Music.class);
            challengeAudio.play();
            activeAudioFile = newActiveAudioFile;
        }
    });
}
项目:dice-heroes    文件:SoundManager.java   
public void playMusicBeautifully(String name, Stage stage) {
    final Music music = musics.get(name);
    if (music == null) {
        Logger.error("there is no music for " + name);
        return;
    }
    music.setVolume(0);
    if (!usesMusic) {
        disabledMusics.add(music);
    } else {
        music.play();
    }
    music.setLooping(true);
    playingMusics.add(music);
    Action action = new TemporalAction(5f, Interpolation.linear) {
        @Override protected void update(float percent) {
            music.setVolume(percent * volume);
        }
    };
    stage.addAction(action);
    replaceAction(music, action);
}
项目:dice-heroes    文件:SoundManager.java   
public void stopMusicBeautifully(String name, Stage stage) {
    final Music music = musics.get(name);
    if (music == null) {
        Logger.error("there is no music for " + name);
        return;
    }
    final float initialVolume = music.getVolume();
    Action action = new TemporalAction(2f, Interpolation.linear) {
        @Override protected void update(float percent) {
            music.setVolume(initialVolume - percent * initialVolume);
        }

        @Override protected void end() {
            music.stop();
            playingMusics.remove(music);
            disabledMusics.remove(music);
        }
    };
    stage.addAction(action);
    replaceAction(music, action);
}
项目:Fruit-Destroyer    文件:LoadingScreen.java   
@Override
public void render(float delta)
{
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    if (APP.assets.update() && !assetsLoaded)
    {
        bg = APP.assets.get("backgrounds/map.png", Texture.class);
        bg.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
        APP.loadingScreen2 = new LoadingScreen2(APP, font, bg);
        menuScreenAtlas = APP.assets.get("atlases/menuscreen.pack", TextureAtlas.class);
        APP.menuScreen = new MenuScreen(APP, font, bg, new MenuHud(APP, APP.viewport, APP.batch, menuScreenAtlas.findRegion("giftiz_logo"), menuScreenAtlas.findRegion("giftiz_logo_badge"), menuScreenAtlas.findRegion("giftiz_logo_warning"), menuScreenAtlas.findRegion("title"), menuScreenAtlas.findRegion("play-button-up"), menuScreenAtlas.findRegion("play-button-down"), menuScreenAtlas.findRegion("highscore-button-up"), menuScreenAtlas.findRegion("highscore-button-down")), APP.assets.get("music/epictheme.ogg", Music.class));
        assetsLoaded = true;
        startTime = System.currentTimeMillis();
    }

    if (assetsLoaded && System.currentTimeMillis() - startTime >= 5000)
        APP.setScreen(APP.menuScreen);

    APP.batch.setProjectionMatrix(APP.camera.combined);
    APP.batch.begin();
    font.render(APP.batch, "Loading", Constants.V_WIDTH / 2, Constants.V_HEIGHT / 2, true);
    APP.batch.end();
}
项目:Inspiration    文件:Assets.java   
public static void loadMusicAsset(String musicFilenamePath){
    if( musicFilenamePath == null || "".equals(musicFilenamePath.trim()) ){
        return;
    }

    if( assetManager.isLoaded(musicFilenamePath) ){
        return;
    }

    //load asset
    if( filePathResolver.resolve(musicFilenamePath).exists() ){
        assetManager.setLoader(Music.class, new MusicLoader(filePathResolver));
        assetManager.load(musicFilenamePath, Music.class);
        //Until we add loading screen, just block until we load the map
        assetManager.finishLoadingAsset(musicFilenamePath);
        Gdx.app.debug(TAG, "Music loaded!: " + musicFilenamePath);
    }
    else{
        Gdx.app.debug(TAG, "Music doesn't exist!: " + musicFilenamePath );
    }
}
项目:Inspiration    文件:AudioManager.java   
private Music playMusic(boolean isLooping, String fullFilePath){
    Music music = _queuedMusic.get(fullFilePath);
    if( music != null ){
        music.setLooping(isLooping);
        music.play();
    }else if(Assets.isAssetLoaded(fullFilePath)){
        music = Assets.getMusicAsset(fullFilePath);
        music.setLooping(isLooping);
        music.play();
        _queuedMusic.put(fullFilePath, music);
    }else{
        Gdx.app.debug(TAG, "Music not loaded");
        return null;
    }
    return music;
}
项目:fabulae    文件:WeatherProfileLoader.java   
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, WeatherProfileParameter parameter) {
    Array<AssetDescriptor> returnValue = new Array<AssetDescriptor>();
    try {
        XmlReader xmlReader = new XmlReader();
        Element root = xmlReader.parse(file);
        LoaderUtil.handleImports(this, parameter, returnValue, file, root);
        Array<Element> trackElements = root.getChildrenByNameRecursively(WeatherProfile.XML_TRACK);
        for (Element trackElement : trackElements) {
            String trackFileName = Configuration.addModulePath(trackElement.get(XMLUtil.XML_ATTRIBUTE_FILENAME));
            returnValue.add(new AssetDescriptor(trackFileName, WeatherProfile.XML_CONTINOUS.equalsIgnoreCase(trackElement.getParent().getName()) ? Music.class : Sound.class)); 
        }
    } catch (IOException e) {
        throw new GdxRuntimeException(e);
    }

    return returnValue;
}
项目:gdx-pd    文件:AudioGdxMusicTest.java   
public static void main(String[] args) 
{
    LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();

    new LwjglApplication(new Game(){
        @Override
        public void create() {

            // play a music
            Music music = Gdx.audio.newMusic(Gdx.files.classpath("cloudconnected.ogg"));
            music.setVolume(0.3f);
            music.play();

            // and a pd patch at the same time
            Pd.audio.create(new PdConfiguration());
            Pd.audio.open(Gdx.files.local("resources/test.pd"));

        }}, config);

}
项目:inari-firefly-libGDX    文件:GdxAudioImpl.java   
@Override
public final void disposeSound( SoundAsset asset ) {
    if ( asset.isStreaming() ) {
        Music music = this.music.remove( asset.index() );
        if ( music != null ) {
            music.dispose();
        }
    } else {
        if ( sounds.contains( asset.index() ) ) {
            com.badlogic.gdx.audio.Sound sound = sounds.remove( asset.index() );
            if ( sound != null ) {
                sound.dispose();
            }
        }
    }
}
项目:gdx-autumn-mvc    文件:InterfaceService.java   
private ActionProvider getDefaultViewShowingActionProvider() {
    return new ActionProvider() {
        @Override
        public Action provideAction(final ViewController forController, final ViewController previousController) {
            if (musicService.getCurrentTheme() == null && GdxArrays.isNotEmpty(forController.getThemes())) {
                final Music currentTheme = forController.getThemes().random();
                return Actions.sequence(Actions.alpha(0f), Actions.fadeIn(DEFAULT_FADING_TIME),
                        Actions.run(CommonActionRunnables.getMusicThemeSetterRunnable(musicService, currentTheme)),
                        Actions.run(CommonActionRunnables.getInputSetterRunnable(forController.getStage())),
                        MusicFadingAction.fadeIn(currentTheme, MusicService.DEFAULT_THEME_FADING_TIME,
                                musicService.getMusicVolume()));
            }
            return Actions.sequence(Actions.alpha(0f), Actions.fadeIn(DEFAULT_FADING_TIME),
                    Actions.run(CommonActionRunnables.getInputSetterRunnable(forController.getStage())));
        }
    };
}
项目:QuickFlix    文件:Assets.java   
public static void init() {
        manager.load("mainassets.pack", TextureAtlas.class);
        Assets.getManager().load("loading.pack", TextureAtlas.class);
//        manager.load("badlogic.jpg", Texture.class);
        manager.load("img/background.png", Texture.class);
        manager.load("img/chairs.png", Texture.class);
        manager.load("img/film_strip.png", Texture.class);
        manager.load("img/ticket.png", Texture.class);
        manager.load("img/bar.png", Texture.class);
        manager.load("title.png", Texture.class);

        manager.load("snd/menu_music.mp3", Music.class);
        manager.load("snd/DST-AlphaTron.mp3", Music.class);
        manager.load("snd/losing_horn.mp3", Sound.class);
        manager.load("snd/pop.ogg", Sound.class);
        manager.load("snd/swoosh.mp3", Sound.class);
        manager.load("snd/wrong_buzzer.mp3", Sound.class);

        manager.load("fnt/yal32.fnt", BitmapFont.class);
        manager.load("fnt/impact-40.fnt", BitmapFont.class);

        manager.load("uiskin.atlas", TextureAtlas.class);
        manager.load("uiskin.json", Skin.class);
        //manager.load("default.fnt", BitmapFont.class);
    }
项目:gdx-lml    文件:InterfaceService.java   
private ActionProvider getDefaultViewShowingActionProvider() {
    return new ActionProvider() {
        @Override
        public Action provideAction(final ViewController forController, final ViewController previousController) {
            if (musicService.getCurrentTheme() == null && GdxArrays.isNotEmpty(forController.getThemes())) {
                final Music currentTheme = forController.getThemes().random();
                return Actions.sequence(Actions.alpha(0f), Actions.fadeIn(DEFAULT_FADING_TIME),
                        Actions.run(CommonActionRunnables.getMusicThemeSetterRunnable(musicService, currentTheme)),
                        Actions.run(CommonActionRunnables.getInputSetterRunnable(forController.getStage())),
                        MusicFadingAction.fadeIn(currentTheme, MusicService.DEFAULT_THEME_FADING_TIME,
                                musicService.getMusicVolume()));
            }
            return Actions.sequence(Actions.alpha(0f), Actions.fadeIn(DEFAULT_FADING_TIME),
                    Actions.run(CommonActionRunnables.getInputSetterRunnable(forController.getStage())));
        }
    };
}
项目:libgdx_mario    文件:MarioBros.java   
@Override
public void create() {
    batch = new SpriteBatch();
    manager = new AssetManager();
    manager.load("audio/music/mario_music.ogg", Music.class);
    manager.load("audio/sounds/coin.wav", Sound.class);
    manager.load("audio/sounds/bump.wav", Sound.class);
    manager.load("audio/sounds/breakblock.wav", Sound.class);
    manager.load("audio/sounds/powerup_spawn.wav", Sound.class);
    manager.load("audio/sounds/powerup.wav", Sound.class);
    manager.load("audio/sounds/powerdown.wav", Sound.class);
    manager.load("audio/sounds/stomp.wav", Sound.class);
    manager.load("audio/sounds/mariodie.wav", Sound.class);
    manager.finishLoading();

    setScreen(new PlayScreen(this));
}
项目:Entitas-Java    文件:AssetsManagerGDX.java   
@Override
public void playMusic(String name) {
    if (!preferencesManager.MUSIC) {
        stopMusic();
        return;
    }
    stopMusic();
    if (assetManager.isLoaded(name, Music.class))
        currentMusicPlaying = assetManager.get(name, Music.class);
    loadAsset(name, Music.class);
    assetManager.finishLoading();

    if (currentMusicPlaying != null) {
        currentMusicPlaying.play();
        currentMusicPlaying.setLooping(true);
        currentMusicPlaying.setVolume(preferencesManager.VOL_MUSIC);
    }
}
项目:Aftamath    文件:GameState.java   
public void updateSound(Vector2 position, Music sound) {
    position = new Vector2(position.x * Vars.PPM, position.y * Vars.PPM);
    float dx = cam.position.x - position.x;
    float dy = cam.position.y - cam.yOff - position.y;
    float distance = (float) Math.sqrt(dx * dx + dy * dy);

    float pan;
    float s = 21400, a = .3183f, f = 5;
    float volume = (float) (Math.exp(-1 * (distance * distance) / (2 * s)) / // Gaussian
                                                                             // curve
            (Math.sqrt((a * Math.PI) / (Game.soundVolume * Game.soundVolume))));
    if (Math.abs(dx) > f)
        pan = (float) -(2 / (1 + Math.exp(-(dx - f * dx / Math.abs(dx)) / 3.5)) - 1); // Logaritmic
                                                                                      // curve
    else
        pan = 0;

    sound.setPan(pan, volume);
}
项目:jumpdontdie    文件:MainGame.java   
@Override
public void create() {
    // Initialize the asset manager. We add every aset to the manager so that it can be loaded
    // inside the LoadingScreen screen. Remember to put the name of the asset in the first
    // argument, then the type of the asset in the second argument.
    manager = new AssetManager();
    manager.load("floor.png", Texture.class);
    manager.load("gameover.png", Texture.class);
    manager.load("overfloor.png", Texture.class);
    manager.load("logo.png", Texture.class);
    manager.load("spike.png", Texture.class);
    manager.load("player.png", Texture.class);
    manager.load("audio/die.ogg", Sound.class);
    manager.load("audio/jump.ogg", Sound.class);
    manager.load("audio/song.ogg", Music.class);

    // Enter the loading screen to load the assets.
    loadingScreen = new LoadingScreen(this);
    setScreen(loadingScreen);
}
项目:network-poker    文件:SoundManager.java   
public static void Init()
{
    backgroundMusic = m.get("audio/bgVoice.ogg", Music.class);
    backgroundMusic.setLooping(true); //ѭ������
    backgroundMusic.setVolume(0.5f); //��������
    //c1
    for(int i=3;i<18;i++)
        sc1[i]=m.get("audio/single"+i+".ogg",Sound.class);
    //c2 c3
    for(int i=3;i<16;i++)
    {
        sc2[i]=m.get("audio/pair"+i+".ogg",Sound.class);
        sc3[i]=m.get("audio/three"+i+".ogg",Sound.class);
    }
    //c4
    sc4[0]=m.get("audio/bomb.ogg",Sound.class);
    sc4[1]=m.get("audio/bombjoker.ogg",Sound.class);
    //c0
    sc0=m.get("audio/pass.ogg",Sound.class);
}
项目:nvlist    文件:NativeAudio.java   
private void doPlay(int loops) {
    Music music = musicRef.get();
    if (music != null) {
        if (loops <= 0) {
            music.setOnCompletionListener(null);
        } else {
            // TODO: Doesn't work on Desktop, unlike Android the completion listener is only called
            //       when the music ends, not on every loop.
            music.setOnCompletionListener(new LoopEndListener());
        }

        loopsLeft.set(loops);
        music.setLooping(loops < 0 || loops > 1);
        applyVolume(); // Re-apply volume in case Music object had to be reloaded
        music.play();
        paused = false;
    }
}
项目:Virtual-Evil    文件:MusicManager.java   
public void initialize() {
    for (String name : songNames) {
        songs.add(Gdx.audio.newMusic(Gdx.files.internal("music/" + name + ".mp3")));
    }

    for (Music song : songs) {
        song.setVolume(VOLUME);
        song.setOnCompletionListener(new Music.OnCompletionListener() {
            @Override
            public void onCompletion(Music music) {
                MusicManager.playNextSong();
            }
        });
    }

    songs.get(0).play();
}
项目:ggvm    文件:SoundtrackManager.java   
/**
 * Plays a song from the assets directory. Stops currently playing song if there is one.
 * Starts playing song from specified position in seconds.
 * @param fileName
 * @param looping
 * @param position
 */
protected void playSong(final String fileName, final boolean looping, final float position) {
    Gdx.app.log(SoundtrackManager.class.getSimpleName(), "playSong(" + fileName + "," + looping + "," + position + ");");
    stopSongs();
    loadSong(fileName);
    Music music = songs.get(fileName);
    currentSong = music;
    currentSongFileName = fileName;
    currentSong.play();
    currentSong.setPosition(position);
    currentSong.setLooping(looping);
}
项目:ggvm    文件:SoundtrackManager.java   
/**
 * Loads a song and associates it with its path.
 * @param fileName
 */
private void loadSong(final String fileName) {
    if (!songs.containsKey(fileName)) {
        Music music = Gdx.audio.newMusic(Gdx.files.internal(fileName));
        songs.put(fileName, music);
    }
}
项目:feup-lpoo-armadillo    文件:Sounds.java   
/**
 * Load the sounds and musics used in the game.
 */
private void loadSounds() {
    assetManager.load("music/Artofescapism_-_Three_Star_Sky.mp3", Music.class);
    assetManager.load("music/item.mp3", Sound.class);
    assetManager.load("music/jump.wav", Sound.class);
    assetManager.load("music/lost.wav", Sound.class);
    assetManager.load("music/won.wav", Sound.class);
    assetManager.load("music/water.wav", Sound.class);
}
项目:feup-lpoo-armadillo    文件:Armadillo.java   
/**
 * Set the Game's Music.
 */
private void setMusic() {
    Music music = Gdx.audio.newMusic(Gdx.files.internal("music/Artofescapism_-_Three_Star_Sky.mp3"));
    music.setVolume(0.5f);
    music.setLooping(true);
    music.play();
}
项目:libgdx-learnlib    文件:Assets.java   
public void init(AssetManager assetManager) {
    this.assetManager = assetManager;
    assetManager.setErrorListener(this);
    assetManager.load(TEXTURE_ATLAS_OBJECTS, TextureAtlas.class);
    // load sounds
    assetManager.load("sounds/jump.wav", Sound.class);
    assetManager.load("sounds/jump_with_feather.wav", Sound.class);
    assetManager.load("sounds/pickup_coin.wav", Sound.class);
    assetManager.load("sounds/pickup_feather.wav", Sound.class);
    assetManager.load("sounds/live_lost.wav", Sound.class);
    // load music
    assetManager.load("music/hair.ogg", Music.class);
    assetManager.finishLoading();

    Gdx.app.debug(TAG, "# of assets loaded: " + assetManager.getAssetNames().size);
    for (String a : assetManager.getAssetNames()) {
        Gdx.app.debug(TAG, "asset: " + a);
    }

    TextureAtlas atlas = assetManager.get(TEXTURE_ATLAS_OBJECTS);

    //激活平滑文理过度
    for (Texture t : atlas.getTextures()) {
        t.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
    }

    //创建游戏资源对象
    bunny = new AssetBunny(atlas);
    rock = new AssetRock(atlas);
    goldCoin = new AssetGoldCoin(atlas);
    feather = new AssetFeather(atlas);
    levelDecoration = new AssetLevelDecoration(atlas);
    sounds = new AssetSounds(assetManager);
    music = new AssetMusic(assetManager);

    fonts = new AssetFonts();
}
项目:penguins-in-space    文件:AssetService.java   
public void loadAudio() {
    assetManager.load(MusicAsset.SOUND_MUSIC_MP3, Music.class);
    assetManager.load(SoundAsset.SOUND_EXPLOSION_WAV, Sound.class);
    assetManager.load(SoundAsset.SOUND_SHOOT_WAV, Sound.class);
    assetManager.load(SoundAsset.SOUND_POWERUP_WAV, Sound.class);
    assetManager.load(SoundAsset.BOMB_DROP, Sound.class);
    assetManager.load(SoundAsset.FIRE_MISSILE, Sound.class);
    assetManager.update();
}
项目:GDX-Engine    文件:DefaultGameAsset.java   
@Override
public Music loadMusic(String fileName,boolean isLoop, float volume)
{
    Music music = Gdx.audio.newMusic(Gdx.files.internal(fileName));
    music.setLooping(true);
    music.setVolume(0.5f);
    return music;
}
项目:SpaceChaos    文件:MainMenuScreen.java   
@Override
public void onResume() {
    // load assets
    assetManager.load(BG_IMAGE_PATH, Texture.class);
    assetManager.load(SELECT_SOUND_PATH, Sound.class);

    // load assets
    assetManager.finishLoadingAsset(BG_IMAGE_PATH);
    assetManager.finishLoadingAsset(SELECT_SOUND_PATH);

    // get assets
    this.bgImage = assetManager.get(BG_IMAGE_PATH, Texture.class);
    Sound selectSound = assetManager.get(SELECT_SOUND_PATH, Sound.class);

    // set hover sounds
    this.newGameButton.setHoverSound(selectSound);
    this.multiplayerButton.setHoverSound(selectSound);
    this.creditsButton.setHoverSound(selectSound);
    this.settingsButton.setHoverSound(selectSound);

    // load and get soundtrack
    assetManager.load(MUSIC_PATH, Music.class);
    assetManager.finishLoadingAsset(MUSIC_PATH);
    this.music = assetManager.get(MUSIC_PATH, Music.class);

    // play background music
    this.music.setVolume(VolumeManager.getInstance().getBackgroundMusicVolume());
    this.music.setLooping(true);
    this.music.play();
}
项目:Polymorph    文件:SettingsScreen.java   
public SettingsScreen(Polymorph polymorph) {
    AssetManager assetManager = polymorph.getAssetManager();
    TextureAtlas textureAtlas = assetManager.get(Polymorph.MASTER_PATH, TextureAtlas.class);

    this.polymorph = polymorph;

    mainMenuMusic = assetManager.get(Polymorph.MAIN_MENU_MUSIC_PATH, Music.class);
    background = textureAtlas.findRegion("settingsscreen");

    stage = new Stage(new StretchViewport(Polymorph.WORLD_WIDTH, Polymorph.WORLD_HEIGHT));
    stage.clear();
    initButtons(textureAtlas);
    Gdx.input.setInputProcessor(stage);
}
项目:Ponytron    文件:SPLASH.java   
private void loadAssets() {
//        playSplashTune();
//        manager.load("fonts/impact_150_mono.fnt", BitmapFont.class);
        manager.load(DS.TEXTURE_ATLAS + ".atlas", TextureAtlas.class);
//        manager.load("audio/fingerless.wav", Music.class);
        manager.load("audio/mad_world_02.mp3", Music.class);
        manager.load("audio/game_over.mp3", Music.class);
        manager.load("audio/shot_sfx.wav", Sound.class);
        manager.load("audio/explosion_sfx.wav", Sound.class);
        manager.load("audio/explosion_03.wav", Sound.class);
        manager.load("audio/yee.wav", Sound.class);
    }