javazoom.jl.player.FactoryRegistry Java Examples

The following examples show how to use javazoom.jl.player.FactoryRegistry. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClipPlayer.java    From triplea with GNU General Public License v3.0 5 votes vote down vote up
private void playClip(final String clipName, final GamePlayer gamePlayer) {
  if (!isSoundEnabled() || isSoundClipMuted(clipName)) {
    return;
  }
  // run in a new thread, so that we do not delay the game
  String folder = clipName;
  if (gamePlayer != null) {
    folder += "_" + gamePlayer.getName();
  }

  final URI clip = loadClip(folder).orElse(loadClip(clipName).orElse(null));
  // clip may still be null, we try to load all phases/all sound, for example: clipName =
  // "phase_technology", folder =
  // "phase_technology_Japanese"

  if (clip != null) {
    new Thread(
            () -> {
              try {
                final Optional<InputStream> inputStream = UrlStreams.openStream(clip.toURL());
                if (inputStream.isPresent()) {
                  final AudioDevice audioDevice =
                      FactoryRegistry.systemRegistry().createAudioDevice();
                  new AdvancedPlayer(inputStream.get(), audioDevice).play();
                }
              } catch (final Exception e) {
                log.log(Level.SEVERE, "Failed to play: " + clip, e);
              }
            })
        .start();
  }
}
 
Example #2
Source File: AdvancedPlayer.java    From jclic with GNU General Public License v2.0 5 votes vote down vote up
public AdvancedPlayer(InputStream stream, AudioDevice device) throws JavaLayerException
{
	bitstream = new Bitstream(stream);

	if (device!=null) audio = device;
	else audio = FactoryRegistry.systemRegistry().createAudioDevice();
	audio.open(decoder = new Decoder());
}
 
Example #3
Source File: AdvancedPlayer.java    From epic-inventor with GNU General Public License v2.0 5 votes vote down vote up
public AdvancedPlayer(InputStream stream, AudioDevice device) throws JavaLayerException {
    bitstream = new Bitstream(stream);

    if (device != null) {
        audio = device;
    } else {
        audio = FactoryRegistry.systemRegistry().createAudioDevice();
    }
    audio.open(decoder = new Decoder());
}