本文整理汇总了Java中javazoom.jl.player.advanced.AdvancedPlayer类的典型用法代码示例。如果您正苦于以下问题:Java AdvancedPlayer类的具体用法?Java AdvancedPlayer怎么用?Java AdvancedPlayer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AdvancedPlayer类属于javazoom.jl.player.advanced包,在下文中一共展示了AdvancedPlayer类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUpMusicPlayer
import javazoom.jl.player.advanced.AdvancedPlayer; //导入依赖的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: speak
import javazoom.jl.player.advanced.AdvancedPlayer; //导入依赖的package包/类
public static synchronized void speak(String text) {
/*
Thread safe method for Text to Speech.
*/
new Thread(
() -> {
try {
synthesiserV2.setSpeed(0.955f);
System.out.println("{->} Speaking : " + text);
AdvancedPlayer advancedPlayer = new AdvancedPlayer(synthesiserV2.getMP3Data(text));
advancedPlayer.play();
} catch (IOException | JavaLayerException exception) {
System.out.println("{X} Exception in TTS. ");
System.out.println(exception.getMessage());
}
}
).start();
}
示例3: play
import javazoom.jl.player.advanced.AdvancedPlayer; //导入依赖的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();
}
}
示例4: play
import javazoom.jl.player.advanced.AdvancedPlayer; //导入依赖的package包/类
public void play() {
final RoomConnection c = this;
new Thread() {
@Override
public void run() {
try {
c.player = new AdvancedPlayer(c.streamIn);
c.player.play();
}
catch (JavaLayerException e) {
e.printStackTrace();
}
}
}.start();
}
示例5: AdvancedPlayerThread
import javazoom.jl.player.advanced.AdvancedPlayer; //导入依赖的package包/类
public AdvancedPlayerThread(String filename, BufferedInputStream bis) {
super(filename);
try {
this.filename = filename;
resetAudioDevice();
this.player = new AdvancedPlayer(bis, audioDevice);
player.setPlayBackListener(playbackListener);
} catch (Exception e) {
Logging.logError(e);
}
}
示例6: playClip
import javazoom.jl.player.advanced.AdvancedPlayer; //导入依赖的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();
}
}
示例7: createPlayer
import javazoom.jl.player.advanced.AdvancedPlayer; //导入依赖的package包/类
/**
* creates the new player
*
* @throws AudioPlayerException
* thrown if advanced player couldn't read inputstream
*/
private void createPlayer() throws AudioPlayerException {
try {
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(path));
this.player = new AdvancedPlayer(bis);
} catch (IOException | JavaLayerException e) {
logger.log(Level.SEVERE, "Error while init audio player:\n" + LogUtil.getStackTrace(e), e);
throw new AudioPlayerException("Error while init file: " + this.path);
}
}
示例8: getPlayer
import javazoom.jl.player.advanced.AdvancedPlayer; //导入依赖的package包/类
public AdvancedPlayer getPlayer() {
return player;
}
示例9: PlayThread
import javazoom.jl.player.advanced.AdvancedPlayer; //导入依赖的package包/类
public PlayThread(AdvancedPlayer player, int startPosition) {
this.player = player;
this.startPosition = startPosition;
}
示例10: setStream
import javazoom.jl.player.advanced.AdvancedPlayer; //导入依赖的package包/类
@Override
public void setStream(InputStream soundStream) throws Exception {
this.mp3player = new AdvancedPlayer(soundStream);
}
示例11: speak
import javazoom.jl.player.advanced.AdvancedPlayer; //导入依赖的package包/类
/**
* Calls the MaryTTS to say the given text
*
* @param text
*/
public void speak(String text) {
System.out.println(text);
//Create a new Thread because JLayer is running on the current Thread and will make the application to lag
Thread thread = new Thread(() -> {
try {
//Create a JLayer instance
AdvancedPlayer player = new AdvancedPlayer(synthesizer.getMP3Data(text));
player.play();
System.out.println("Successfully got back synthesizer data");
} catch (IOException | JavaLayerException e) {
e.printStackTrace(); //Print the exception ( we want to know , not hide below our finger , like many developers do...)
}
});
//We don't want the application to terminate before this Thread terminates
thread.setDaemon(false);
//Start the Thread
thread.start();
}
示例12: Play2Thread
import javazoom.jl.player.advanced.AdvancedPlayer; //导入依赖的package包/类
/**
* Constructor for the Play2Thread object
*
* @param ap Description of the Parameter
* @param skip1 Description of the Parameter
* @param skip2 Description of the Parameter
*/
public Play2Thread(AdvancedPlayer ap, int skip1, int skip2) {
this.ap = ap;
this.skip1 = skip1;
this.skip2 = skip2;
}