Search in sources :

Example 1 with DecodedTrackHolder

use of com.sedmelluq.discord.lavaplayer.track.DecodedTrackHolder 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 DecodedTrackHolder

use of com.sedmelluq.discord.lavaplayer.track.DecodedTrackHolder in project lavaplayer by sedmelluq.

the class DefaultAudioPlayerManager method decodeTrack.

@Override
public DecodedTrackHolder decodeTrack(MessageInput stream) throws IOException {
    DataInput input = stream.nextMessage();
    if (input == null) {
        return null;
    }
    int version = (stream.getMessageFlags() & TRACK_INFO_VERSIONED) != 0 ? (input.readByte() & 0xFF) : 1;
    AudioTrackInfo trackInfo = new AudioTrackInfo(input.readUTF(), input.readUTF(), input.readLong(), input.readUTF(), input.readBoolean(), version >= 2 ? DataFormatTools.readNullableText(input) : null);
    AudioTrack track = decodeTrackDetails(trackInfo, input);
    long position = input.readLong();
    if (track != null) {
        track.setPosition(position);
    }
    stream.skipRemainingBytes();
    return new DecodedTrackHolder(track);
}
Also used : DataInput(java.io.DataInput) DecodedTrackHolder(com.sedmelluq.discord.lavaplayer.track.DecodedTrackHolder) AudioTrackInfo(com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo) InternalAudioTrack(com.sedmelluq.discord.lavaplayer.track.InternalAudioTrack) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack)

Aggregations

DecodedTrackHolder (com.sedmelluq.discord.lavaplayer.track.DecodedTrackHolder)2 BotCommandHandler (com.sedmelluq.discord.lavaplayer.demo.controller.BotCommandHandler)1 MessageInput (com.sedmelluq.discord.lavaplayer.tools.io.MessageInput)1 AudioTrack (com.sedmelluq.discord.lavaplayer.track.AudioTrack)1 AudioTrackInfo (com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo)1 InternalAudioTrack (com.sedmelluq.discord.lavaplayer.track.InternalAudioTrack)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInput (java.io.DataInput)1