@Override public void run() { while (is_playing) { try { Thread.sleep(1000); synchronized (this) { if (current_task != null) { if (current_task.update()) {} if (!current_task.isPlaying()) { current_task.play(true); } } } } catch (Throwable ex) { ex.printStackTrace(); } } }
public static void main(String[] args) throws Throwable { // String url = "D:\\Projects\\EatWorld\\trunk\\data\\edit\\resource\\sound\\WC0002.ogg"; String url = "http://game.lordol.com/eatworld_test/sound/WC0001.ogg"; // OggDecoder dec = new OggDecoder(); // SoundInfo info = dec.decode(url, CIO.loadStream(url)); // System.out.println("Done : decode \n" + info.toString()); // OggStreamSoundInfo stream = new OggStreamSoundInfo(url, CIO.getInputStream(url)); // // Thread t = new Thread(stream); // t.start(); // int total = 0; // while (t.isAlive()) { // if (stream.hasData()) { // ByteBuffer buffer = stream.getData(); // int readed = buffer.remaining(); // System.out.println("stream " + readed + " bytes, total " + // CUtil.getBytesSizeString(total)); // total += readed; // } // Thread.sleep(1000); // } SoundManager.setSoundManager(JALSoundManager.getInstance()); StreamSoundPlayer player = new StreamSoundPlayer( SoundManager.getSoundManager().createPlayer(), new OggStreamSoundInfo(url, CIO.getInputStream(url))); while (true) { if (!player.update()) { if (!player.isPlaying()) { player.play(true); } } // System.out.println("stream completed !"); Thread.sleep(500); } }
public void playBGM() { loading.start(); }