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

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

Introduction

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

Prototype

public boolean isPlaying() 

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//from ww w.  j  a  v  a 2s.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();
}