本文整理汇总了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;
}
}
示例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();
}
}
示例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());
}
示例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();
}
}
示例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());
}
示例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());
}
示例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;
}