Search in sources :

Example 1 with BotCommandHandler

use of com.sedmelluq.discord.lavaplayer.demo.controller.BotCommandHandler in project lavaplayer by sedmelluq.

the class MusicController method deserialize.

@BotCommandHandler
private void deserialize(Message message, String content) throws IOException {
    outputChannel.set((TextChannel) message.getChannel());
    connectToFirstVoiceChannel(guild.getAudioManager());
    byte[] bytes = Base64.decode(content);
    MessageInput inputStream = new MessageInput(new ByteArrayInputStream(bytes));
    DecodedTrackHolder holder;
    while ((holder = manager.decodeTrack(inputStream)) != null) {
        if (holder.decodedTrack != null) {
            scheduler.addToQueue(holder.decodedTrack);
        }
    }
}
Also used : DecodedTrackHolder(com.sedmelluq.discord.lavaplayer.track.DecodedTrackHolder) ByteArrayInputStream(java.io.ByteArrayInputStream) MessageInput(com.sedmelluq.discord.lavaplayer.tools.io.MessageInput) BotCommandHandler(com.sedmelluq.discord.lavaplayer.demo.controller.BotCommandHandler)

Example 2 with BotCommandHandler

use of com.sedmelluq.discord.lavaplayer.demo.controller.BotCommandHandler in project lavaplayer by sedmelluq.

the class MusicController method serialize.

@BotCommandHandler
private void serialize(Message message) throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    MessageOutput outputStream = new MessageOutput(baos);
    for (AudioTrack track : scheduler.drainQueue()) {
        manager.encodeTrack(outputStream, track);
    }
    outputStream.finish();
    message.getChannel().sendMessage(Base64.encodeBytes(baos.toByteArray())).queue();
}
Also used : MessageOutput(com.sedmelluq.discord.lavaplayer.tools.io.MessageOutput) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) ByteArrayOutputStream(java.io.ByteArrayOutputStream) BotCommandHandler(com.sedmelluq.discord.lavaplayer.demo.controller.BotCommandHandler)

Example 3 with BotCommandHandler

use of com.sedmelluq.discord.lavaplayer.demo.controller.BotCommandHandler in project lavaplayer by sedmelluq.

the class MusicController method nodeinfo.

@BotCommandHandler
private void nodeinfo(Message message) {
    for (RemoteNode node : manager.getRemoteNodeRegistry().getNodes()) {
        String report = buildReportForNode(node);
        message.getChannel().sendMessage(report).queue();
    }
}
Also used : RemoteNode(com.sedmelluq.discord.lavaplayer.remote.RemoteNode) BotCommandHandler(com.sedmelluq.discord.lavaplayer.demo.controller.BotCommandHandler)

Aggregations

BotCommandHandler (com.sedmelluq.discord.lavaplayer.demo.controller.BotCommandHandler)3 RemoteNode (com.sedmelluq.discord.lavaplayer.remote.RemoteNode)1 MessageInput (com.sedmelluq.discord.lavaplayer.tools.io.MessageInput)1 MessageOutput (com.sedmelluq.discord.lavaplayer.tools.io.MessageOutput)1 AudioTrack (com.sedmelluq.discord.lavaplayer.track.AudioTrack)1 DecodedTrackHolder (com.sedmelluq.discord.lavaplayer.track.DecodedTrackHolder)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1