当前位置: 首页>>代码示例>>Java>>正文


Java FactoryRegistry类代码示例

本文整理汇总了Java中javazoom.jl.player.FactoryRegistry的典型用法代码示例。如果您正苦于以下问题:Java FactoryRegistry类的具体用法?Java FactoryRegistry怎么用?Java FactoryRegistry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FactoryRegistry类属于javazoom.jl.player包,在下文中一共展示了FactoryRegistry类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUpMusicPlayer

import javazoom.jl.player.FactoryRegistry; //导入依赖的package包/类
/**
 * Helper function to setup a new instance of a music player based on the song that is passed in.
 *
 * @param songToPlay The song that you want to set up the music player for.
 */
private void setUpMusicPlayer(Song songToPlay) throws Exception{
    try {
        m_isUserInterrupted = false;
        m_fs = new FileInputStream(songToPlay.getFile());
        m_bufferedStream = new BufferedInputStream(m_fs);
        m_audioDevice = FactoryRegistry.systemRegistry().createAudioDevice();

        m_player = new AdvancedPlayer(m_bufferedStream, m_audioDevice);
        m_player.setPlayBackListener(createPlaybackListeners());

        m_isReady = true;
    } catch (Exception e) {
        e.printStackTrace();
        m_manager.setError(e);
        m_manager.notifyError();
        throw e;
    }
}
 
开发者ID:ijh165,项目名称:Gamma-Music-Manager,代码行数:24,代码来源:JlayerMP3Player.java

示例2: play

import javazoom.jl.player.FactoryRegistry; //导入依赖的package包/类
@Override
public void play(Song song, SongAudio songAudio) {
    this.currentSong = song;
    RenderedSong renderedSong = songPersistenceService.getRenderedSongById(song.getId()).orElse(new RenderedSong());
    this.renderedChannelMap = new Gson().fromJson(renderedSong.getRenderData(), RenderedChannelMap.class);

    try {
        FactoryRegistry r = FactoryRegistry.systemRegistry();
        audioDevice = r.createAudioDevice();

        ByteArrayInputStream inputStream = new ByteArrayInputStream(songAudio.getAudioData());
        AdvancedPlayer player = new AdvancedPlayer(inputStream, audioDevice);
        player.setPlayBackListener(playbackListener);
        player.play();
    } catch (JavaLayerException e) {
        e.printStackTrace();
    }
}
 
开发者ID:sparkled,项目名称:sparkled,代码行数:19,代码来源:SongPlayerServiceImpl.java

示例3: AdvancedPlayer

import javazoom.jl.player.FactoryRegistry; //导入依赖的package包/类
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());
}
 
开发者ID:EndlessBot,项目名称:jLib,代码行数:9,代码来源:AdvancedPlayer.java

示例4: playClip

import javazoom.jl.player.FactoryRegistry; //导入依赖的package包/类
private void playClip(final String clipName, final PlayerID playerId) {
  if (beSilent || isMuted(clipName)) {
    return;
  }
  // run in a new thread, so that we do not delay the game
  String folder = clipName;
  if (playerId != null) {
    folder += "_" + playerId.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) {
        ClientLogger.logError("Failed to play: " + clip, e);
      }
    }).start();
  }
}
 
开发者ID:triplea-game,项目名称:triplea,代码行数:29,代码来源:ClipPlayer.java

示例5: AdvancedPlayer

import javazoom.jl.player.FactoryRegistry; //导入依赖的package包/类
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());
}
 
开发者ID:kuhnmi,项目名称:jukefox,代码行数:10,代码来源:AdvancedPlayer.java

示例6: AdvancedPlayer

import javazoom.jl.player.FactoryRegistry; //导入依赖的package包/类
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());
}
 
开发者ID:BlkStormy,项目名称:epic-inventor,代码行数:11,代码来源:AdvancedPlayer.java

示例7: play

import javazoom.jl.player.FactoryRegistry; //导入依赖的package包/类
public boolean play(int frameIndexStart, int frameIndexFinal,
		int correctionFactorInFrames) throws JavaLayerException {
	try {
		this.bitstream = new Bitstream(this.getAudioInputStream());
	} catch (IOException e) {
		e.printStackTrace();
	}
	this.audioDevice = FactoryRegistry.systemRegistry().createAudioDevice();
	this.decoder = new Decoder();
	this.audioDevice.open(this.decoder);

	boolean shouldContinueReadingFrames = true;

	this.paused = false;
	this.stopped = false;
	this.frameIndexCurrent = 0;

	while (shouldContinueReadingFrames == true
			&& this.frameIndexCurrent < frameIndexStart
					- correctionFactorInFrames) {
		shouldContinueReadingFrames = this.skipFrame();
		this.frameIndexCurrent++;
	}

	if (this.listener != null) {
		this.listener.playbackStarted(new PlaybackEvent(this,
				PlaybackEvent.EventType.Started, this.audioDevice
						.getPosition()));
	}

	if (frameIndexFinal < 0) {
		frameIndexFinal = Integer.MAX_VALUE;
	}

	while (shouldContinueReadingFrames == true
			&& this.frameIndexCurrent < frameIndexFinal) {
		if (this.paused || this.stopped) {
			shouldContinueReadingFrames = false;
			try {
				Thread.sleep(1);
			} catch (Exception ex) {
				ex.printStackTrace();
			}
		} else {
			shouldContinueReadingFrames = this.decodeFrame();
			this.frameIndexCurrent++;
		}
	}

	// last frame, ensure all data flushed to the audio device.
	if (this.audioDevice != null && !this.paused) {
		this.audioDevice.flush();

		synchronized (this) {
			this.complete = (this.closed == false);
			this.close();
		}

		// report to listener
		if (this.listener != null) {
			int audioDevicePosition = -1;
			if (this.audioDevice != null) {
				audioDevicePosition = this.audioDevice.getPosition();
			} else {
				// throw new
				// NullPointerException("attribute audioDevice in " +
				// this.getClass() + " is NULL");
			}
			PlaybackEvent playbackEvent = new PlaybackEvent(this,
					PlaybackEvent.EventType.Stopped,
					audioDevicePosition);
			this.listener.playbackFinished(playbackEvent);
		}
	}

	return shouldContinueReadingFrames;
}
 
开发者ID:git-commit,项目名称:radio-activity,代码行数:78,代码来源:JLayerPlayerPausable.java


注:本文中的javazoom.jl.player.FactoryRegistry类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。