public static Audio playWav(String wavFile, boolean loop) { try { AudioLoader.update(); // JIC Audio wav = AudioLoader.getAudio("WAV", ResourceLoader.getResourceAsStream(wavFile)); sounds.add(wav); wav.playAsMusic(1.0f, 1.0f, loop); return wav; } catch (IOException e) { e.printStackTrace(); } return null; }
/** Initialise resources */ public void init() { try { wavEffect = AudioLoader.getAudio( "WAV", ResourceLoader.getResourceAsStream("com/etk2000/SpaceGame/Music/MainMenuMusic.wav")); // @param: something, something, loop wavEffect.playAsMusic(1.0f, 1.0f, true); } catch (Exception e) { System.out.println(e.getMessage()); } /* * try { * // you can play oggs by loading the complete thing into * // a sound * oggEffect = AudioLoader.getAudio("OGG", * ResourceLoader.getResourceAsStream("testdata/restart.ogg")); * * // or setting up a stream to read from. Note that the argument becomes * // a URL here so it can be reopened when the stream is complete. Probably * // should have reset the stream by thats not how the original stuff worked * oggStream = AudioLoader.getStreamingAudio("OGG", * ResourceLoader.getResource("testdata/bongos.ogg")); * * // can load mods (XM, MOD) using ibxm which is then played through OpenAL. MODs * // are always streamed based on the way IBXM works * modStream = AudioLoader.getStreamingAudio("MOD", * ResourceLoader.getResource("testdata/SMB-X.XM")); * * // playing as music uses that reserved source to play the sound. The first * // two arguments are pitch and gain, the boolean is whether to loop the content * modStream.playAsMusic(1.0f, 1.0f, true); * * // you can play aifs by loading the complete thing into * // a sound * aifEffect = AudioLoader.getAudio("AIF", * ResourceLoader.getResourceAsStream("testdata/burp.aif")); * * // you can play wavs by loading the complete thing into * // a sound * wavEffect = AudioLoader.getAudio("WAV", * ResourceLoader.getResourceAsStream("testdata/cbrown01.wav")); * } catch (Exception e) { * e.printStackTrace(); * } */ }
public static void initEffects() throws IOException { pokeball = TextureLoader.getTexture("PNG", Main.class.getResourceAsStream("/resources/ball.png")); // Need to wrap with BufferedInputStream // See: https://stackoverflow.com/questions/5529754/java-io-ioexception-mark-reset-not-supported leftReturn = AudioLoader.getAudio( "WAV", new BufferedInputStream(Main.class.getResourceAsStream("/resources/left.wav"))); rightReturn = AudioLoader.getAudio( "WAV", new BufferedInputStream(Main.class.getResourceAsStream("/resources/right.wav"))); }
@Override public Audio loadAudio(final InputStream in) throws IOException { if (in == null) return null; org.newdawn.slick.openal.Audio retval = AudioLoader.getAudio("OGG", in); if (retval == null) return null; return new LWJGLAudioAdapter(retval); }
public static void playMusic(String name) { try { Audio song; song = AudioLoader.getAudio( "WAV", ResourceLoader.getResourceAsStream( "resources" + Common.sep + "music" + Common.sep + name + ".wav")); song.playAsMusic(1.0f, 1.0f, true); } catch (Exception e) { e.printStackTrace(); } }
@Override public void update() { Display.update(); AudioLoader.update(); }