public SoundPlayer() {
    libraryType = LibraryJavaSound.class;

    try {
      SoundSystemConfig.setCodec("ogg", CodecJOrbis.class);
    } catch (SoundSystemException ex) {
      oggPlaybackSupport = false;
    }

    try {
      SoundSystemConfig.setCodec("wav", CodecWav.class);
    } catch (SoundSystemException ex) {
      wavPlaybackSupport = false;
    }

    try {
      soundSystem = new SoundSystem(libraryType);
    } catch (SoundSystemException ex) {
      soundSystem = null;
    }
  }
  private boolean playSound(String sourceName, float x, float y, boolean blocking, int index) {
    if (index < MAX_SOURCES_PER_SOUND && !isMuted() && hasWavPlaybackSupport()) {
      String indexedSourceName = sourceName + index;
      if (!loaded.contains(indexedSourceName)) {
        soundSystem.newSource(
            false,
            indexedSourceName,
            SoundPlayer.class.getResource(sourceName),
            sourceName,
            false,
            x,
            y,
            0,
            SoundSystemConfig.ATTENUATION_ROLLOFF,
            SoundSystemConfig.getDefaultRolloff());
        loaded.add(indexedSourceName);
      } else if (isPlaying(indexedSourceName)) {
        if (blocking) {
          return false;
        }

        // Source already playing, create new source for same sound
        // effect.
        return playSound(sourceName, x, y, false, index + 1);
      }
      soundSystem.stop(indexedSourceName);
      soundSystem.setPriority(indexedSourceName, false);
      soundSystem.setPosition(indexedSourceName, x, y, 0);
      soundSystem.setAttenuation(indexedSourceName, SoundSystemConfig.ATTENUATION_ROLLOFF);
      soundSystem.setDistOrRoll(indexedSourceName, SoundSystemConfig.getDefaultRolloff());
      soundSystem.setPitch(indexedSourceName, 1.0f);
      soundSystem.play(indexedSourceName);
      return true;
    }
    return false;
  }