use of com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager in project FredBoat by Frederikam.
the class AudioPlayerManagerConfiguration method preconfiguredAudioPlayerManager.
/**
* @return a preconfigured AudioPlayerManager, no AudioSourceManagers set
*/
@Bean(destroyMethod = "")
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public AudioPlayerManager preconfiguredAudioPlayerManager(AppConfig appConfig) {
AudioPlayerManager playerManager = new DefaultAudioPlayerManager();
// Patrons and development get higher quality
AudioConfiguration.ResamplingQuality quality = AudioConfiguration.ResamplingQuality.LOW;
if (appConfig.isPatronDistribution() || appConfig.isDevDistribution()) {
quality = AudioConfiguration.ResamplingQuality.MEDIUM;
}
playerManager.getConfiguration().setResamplingQuality(quality);
playerManager.setFrameBufferDuration(1000);
playerManager.setItemLoaderThreadPoolSize(500);
return playerManager;
}
use of com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager in project lavaplayer by sedmelluq.
the class LocalPlayerDemo method main.
public static void main(String[] args) throws LineUnavailableException, IOException {
AudioPlayerManager manager = new DefaultAudioPlayerManager();
AudioSourceManagers.registerRemoteSources(manager);
manager.getConfiguration().setOutputFormat(new AudioDataFormat(2, 44100, 960, AudioDataFormat.Codec.PCM_S16_BE));
AudioPlayer player = manager.createPlayer();
manager.loadItem("ytsearch: epic soundtracks", new FunctionalResultHandler(null, playlist -> {
player.playTrack(playlist.getTracks().get(0));
}, null, null));
AudioDataFormat format = manager.getConfiguration().getOutputFormat();
AudioInputStream stream = AudioPlayerInputStream.createStream(player, format, 10000L, false);
SourceDataLine.Info info = new DataLine.Info(SourceDataLine.class, stream.getFormat());
SourceDataLine line = (SourceDataLine) AudioSystem.getLine(info);
line.open(stream.getFormat());
line.start();
byte[] buffer = new byte[format.bufferSize(2)];
int chunkSize;
while ((chunkSize = stream.read(buffer)) >= 0) {
line.write(buffer, 0, chunkSize);
}
}
Aggregations