Example usage for com.badlogic.gdx.backends.lwjgl.audio OpenALMusic update

List of usage examples for com.badlogic.gdx.backends.lwjgl.audio OpenALMusic update

Introduction

In this page you can find the example usage for com.badlogic.gdx.backends.lwjgl.audio OpenALMusic update.

Prototype

public void update() 

Source Link

Usage

From source file:phasereditor.audio.core.AudioCore.java

License:Open Source License

private static void initGdxAudio() {
    GdxNativesLoader.disableNativesLoading = true;
    _musicsToUpdate = new ArrayList<>();
    _musicActionsToUpdate = new ArrayList<>();

    // music loop

    Thread th = new Thread("Phaser Editor music loop") {
        @Override/*  w w w  .  j a v a2s.c  om*/
        public void run() {
            while (true) {
                try {
                    sleep(100);
                } catch (InterruptedException e) {
                    // nothing
                }
                synchronized (_musicsToUpdate) {
                    for (OpenALMusic music : _musicsToUpdate) {
                        synchronized (music) {
                            if (music.isPlaying()) {
                                music.update();
                            }
                        }
                    }
                }

                synchronized (_musicActionsToUpdate) {
                    for (Runnable action : _musicActionsToUpdate) {
                        try {
                            action.run();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
    };
    th.setDaemon(true);
    th.start();
}