本文整理汇总了Java中com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers类的典型用法代码示例。如果您正苦于以下问题:Java AudioSourceManagers类的具体用法?Java AudioSourceManagers怎么用?Java AudioSourceManagers使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AudioSourceManagers类属于com.sedmelluq.discord.lavaplayer.source包,在下文中一共展示了AudioSourceManagers类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers; //导入依赖的package包/类
public static void main(final String[] args) throws Exception {
Thread.currentThread().setName("JukeBot-Main");
ConfigurationFactory.setConfigurationFactory(new Log4JConfig());
LOG = LogManager.getLogger("JukeBot");
playerManager = new DefaultAudioPlayerManager();
defaultPrefix = Database.getPropertyFromConfig("prefix");
String colour = Database.getPropertyFromConfig("color");
if (colour.equalsIgnoreCase("")) {
LOG.error("Missing property 'color' in the database.");
return;
}
embedColour = Color.decode(colour);
playerManager.setPlayerCleanupThreshold(30000);
playerManager.getConfiguration().setResamplingQuality(AudioConfiguration.ResamplingQuality.LOW);
playerManager.getConfiguration().setOpusEncodingQuality(9);
YoutubeAudioSourceManager yt = new YoutubeAudioSourceManager();
yt.setPlaylistPageCount(Integer.MAX_VALUE);
playerManager.registerSourceManager(yt);
AudioSourceManagers.registerRemoteSources(playerManager);
printBanner();
shardManager = new DefaultShardManagerBuilder()
.setToken(Database.getPropertyFromConfig("token"))
.setShardsTotal(-1)
.addEventListeners(new EventListener(), waiter)
.setAudioSendFactory(new NativeAudioSendFactory())
.setGame(Game.of(Game.GameType.LISTENING, defaultPrefix + "help | jukebot.xyz"))
.build();
}
示例2: loadDiscord
import com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers; //导入依赖的package包/类
public void loadDiscord() {
try {
jda = new JDABuilder(AccountType.BOT)
.setToken(DiscordBot.getInstance().getConfig().getToken())
.addEventListener(new DiscordListener())
.setAudioEnabled(true)
.setBulkDeleteSplittingEnabled(false)
.buildAsync();
AudioSourceManagers.registerRemoteSources(getAudioPlayerManager());
audioPlayer = getAudioPlayerManager().createPlayer();
getAudioPlayer().setVolume(DiscordBot.getInstance().getConfig().getDefaultVolume());
getAudioPlayer().addListener(new AudioListener());
getDiscordThread().start();
getCommand().registerCommands();
LogHelper.info("Successfully loaded Discord.");
} catch (LoginException | RateLimitedException | RuntimeException ex) {
LogHelper.error("Exception loading Discord!");
ex.printStackTrace();
}
}
示例3: main
import com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers; //导入依赖的package包/类
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);
}
}
示例4: init
import com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers; //导入依赖的package包/类
static void init() {
playerManager = new DefaultAudioPlayerManager();
AudioSourceManagers.registerRemoteSources(playerManager);
AudioSourceManagers.registerLocalSource(playerManager);
initGuildAudioPlayer(Bot.getGuild());
Log.debug("Initialized audio player.");
}
示例5: main
import com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers; //导入依赖的package包/类
public static void main(String[] args) {
/* Set up the player manager */
PLAYER_MANAGER.enableGcMonitoring();
PLAYER_MANAGER.setItemLoaderThreadPoolSize(100);
PLAYER_MANAGER.getConfiguration().setResamplingQuality(AudioConfiguration.ResamplingQuality.LOW);
AudioSourceManagers.registerRemoteSources(PLAYER_MANAGER);
log.info("Loading AudioTracks");
String identifier;
if (args.length >= 1 && args[0].equals("opus")) {
identifier = DEFAULT_OPUS;
} else {
identifier = DEFAULT_PLAYLIST;
}
tracks = new PlaylistLoader().loadTracksSync(identifier);
log.info(tracks.size() + " tracks loaded. Beginning benchmark...");
try {
doLoop();
} catch (Exception e) {
log.error("Benchmark ended due to exception!");
throw new RuntimeException(e);
}
System.exit(0);
}
示例6: Bot
import com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers; //导入依赖的package包/类
public Bot(EventWaiter waiter, Config config)
{
this.config = config;
this.waiter = waiter;
this.settings = new HashMap<>();
this.lastNP = new HashMap<>();
manager = new DefaultAudioPlayerManager();
threadpool = Executors.newSingleThreadScheduledExecutor();
AudioSourceManagers.registerRemoteSources(manager);
AudioSourceManagers.registerLocalSource(manager);
manager.source(YoutubeAudioSourceManager.class).setPlaylistPageCount(10);
try {
JSONObject loadedSettings = new JSONObject(new String(Files.readAllBytes(Paths.get("serversettings.json"))));
loadedSettings.keySet().forEach((id) -> {
JSONObject o = loadedSettings.getJSONObject(id);
settings.put(id, new Settings(
o.has("text_channel_id") ? o.getString("text_channel_id") : null,
o.has("voice_channel_id")? o.getString("voice_channel_id"): null,
o.has("dj_role_id") ? o.getString("dj_role_id") : null,
o.has("volume") ? o.getInt("volume") : 100,
o.has("default_playlist")? o.getString("default_playlist"): null,
o.has("repeat") ? o.getBoolean("repeat") : false));
});
} catch(IOException | JSONException e) {
LoggerFactory.getLogger("Settings").warn("Failed to load server settings (this is normal if no settings have been set yet): "+e);
}
}
示例7: Main
import com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers; //导入依赖的package包/类
private Main() {
this.musicManagers = new HashMap<>();
this.playerManager = new DefaultAudioPlayerManager();
AudioSourceManagers.registerRemoteSources(playerManager);
AudioSourceManagers.registerLocalSource(playerManager);
}
示例8: PlayingTrackManager
import com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers; //导入依赖的package包/类
@Autowired
public PlayingTrackManager(StatisticsManager statisticsManager) {
this.statisticsManager = statisticsManager;
manager = new DefaultAudioPlayerManager();
tracks = new ConcurrentHashMap<>();
manager.setUseSeekGhosting(false);
AudioSourceManagers.registerRemoteSources(manager);
}
示例9: MusicPlayer
import com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers; //导入依赖的package包/类
public MusicPlayer() {
this.musicManagers = new HashMap<>();
this.playerManager = new DefaultAudioPlayerManager();
AudioSourceManagers.registerRemoteSources(playerManager);
AudioSourceManagers.registerLocalSource(playerManager);
}
示例10: initDiscord
import com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers; //导入依赖的package包/类
public void initDiscord(){
//Init lavaplayer
Karren.log.info("Starting up Lavaplayer...");
gms = new HashMap<>();
AudioSourceManagers.registerRemoteSources(pm);
AudioSourceManagers.registerLocalSource(pm);
//Continue connecting to discord
if(Karren.conf.getConnectToDiscord()) {
EventDispatcher ed = client.getDispatcher();
ed.registerListener(new ConnectCommand());
try {
client.login();
} catch (DiscordException | RateLimitException e) {
e.printStackTrace();
}
ed.registerListener(new HelpCommand());
ed.registerListener(interactionListener);
ed.registerListener(new KillCommand());
ed.registerListener(new GuildCreateListener());
ed.registerListener(new ShutdownListener());
ed.registerListener(new ReconnectListener());
ed.registerListener(new StatCommand());
initExtras();
} else {
Karren.log.info("Running in test mode, not connected to Discord.");
initExtras();
//Init interaction processor
}
}
示例11: MusicCommand
import com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers; //导入依赖的package包/类
public MusicCommand() {
AudioSourceManagers.registerRemoteSources(manager);
}
示例12: Music
import com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers; //导入依赖的package包/类
public Music() {
AudioSourceManagers.registerRemoteSources(myManager);
}
示例13: Bot
import com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers; //导入依赖的package包/类
Bot(EventWaiter waiter) {
this.waiter = waiter;
this.manager = new DefaultAudioPlayerManager();
AudioSourceManagers.registerRemoteSources(manager);
}
示例14: Music
import com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers; //导入依赖的package包/类
public Music() {
this.musicManagers = new HashMap<>();
this.playerManager = new DefaultAudioPlayerManager();
AudioSourceManagers.registerRemoteSources(playerManager);
AudioSourceManagers.registerLocalSource(playerManager);
}
示例15: onReadyEvent
import com.sedmelluq.discord.lavaplayer.source.AudioSourceManagers; //导入依赖的package包/类
@EventSubscriber
public void onReadyEvent(ReadyEvent event) { // This method is called when the ReadyEvent is dispatched
Console.println("Bot login success");
Console.println("Shards: " + INIT.BOT.getShardCount());
StringBuilder serverstr = new StringBuilder();
int count = 1;
for (IGuild server : INIT.BOT.getGuilds()) {
serverstr.append("\n")
.append(count)
.append(". [")
.append(server.getName())
.append(" ")
.append(server.getStringID())
.append("]");
count++;
}
Console.println("Servers: " + serverstr);
RegisterCommands.registerAll();
Console.println("Loading Permissions from SaveFile");
PERM.loadPermissions(INIT.BOT.getGuilds());
PERM.setDefaultPermissions(INIT.BOT.getGuilds(), false);
INIT.BOT.changePlayingText(DRIVER.getPropertyOnly(DRIVER.CONFIG, "defaultplaying").toString());
INIT.BOT.changeUsername(DRIVER.getPropertyOnly(DRIVER.CONFIG, "defaultUsername").toString());
Console.println("Loading Command Descriptions");
for (Command command : COMMAND.getAllCommands()) {
LANG.getMethodDescription(command);
}
Console.println("Register Audioprovider");
AudioSourceManagers.registerRemoteSources(MainMusic.playerManager);
AudioSourceManagers.registerLocalSource(MainMusic.playerManager);
RoleManagement.loadGenders();
saveGuilds();
Console.println("====================================Bot Status========================================");
INIT.BOT.getShards().forEach(iShard -> {
Console.println("Shard "+iShard.getInfo()[0]+": "+iShard.isReady()+" Servers: "+iShard.getGuilds().size()+" Ping: "+iShard.getResponseTime());
});
Optional stream = INIT.BOT.getOurUser().getPresence().getStreamingUrl();
Optional playtext = INIT.BOT.getOurUser().getPresence().getPlayingText();
Console.println("Username: "+INIT.BOT.getOurUser().getName());
Console.println("Status: "+INIT.BOT.getOurUser().getPresence().getStatus());
if (stream.isPresent()) {
Console.println("Streaming: "+stream.get());
} else {
Console.println("Streaming: OFFLINE");
}
if (playtext.isPresent()) {
Console.println("Playing: "+playtext.get());
} else {
Console.println("Playing: NOTHING");
}
SystemInfo info = new SystemInfo();
Console.println("SystemInfo: "+info.Info()+"\n");
Command helpcommand = COMMAND.getCommandByName("help");
Console.println("Type "+ DRIVER.getPropertyOnly(DRIVER.CONFIG, "botprefix").toString()+helpcommand.prefix()+helpcommand.command()+" for getting help.");
Console.println("====================================Bot Start completed===============================");
running = true;
}