Ejemplo n.º 1
0
 // Статический метод, для удобства
 public static Sound playSound(String s, float volume) {
   File f = new File(s);
   Sound snd = new Sound(f);
   snd.setVolume(volume);
   snd.play();
   return snd;
 }
Ejemplo n.º 2
0
  /**
   * Plays a sound with an optional SoundFilter, and optionally looping. This method returns
   * immediately.
   */
  public InputStream play(Sound sound, SoundFilter filter, boolean loop) {
    InputStream is;
    if (sound != null) {
      if (loop) {
        is = new LoopingByteInputStream(sound.getSamples());
      } else {
        is = new ByteArrayInputStream(sound.getSamples());
      }

      return play(is, filter);
    }
    return null;
  }