com.sedmelluq.discord.lavaplayer.tools.io.MessageOutput Java Examples
The following examples show how to use
com.sedmelluq.discord.lavaplayer.tools.io.MessageOutput.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultAudioPlayerManager.java From lavaplayer with Apache License 2.0 | 6 votes |
@Override public void encodeTrack(MessageOutput stream, AudioTrack track) throws IOException { DataOutput output = stream.startMessage(); output.write(TRACK_INFO_VERSION); AudioTrackInfo trackInfo = track.getInfo(); output.writeUTF(trackInfo.title); output.writeUTF(trackInfo.author); output.writeLong(trackInfo.length); output.writeUTF(trackInfo.identifier); output.writeBoolean(trackInfo.isStream); DataFormatTools.writeNullableText(output, trackInfo.uri); encodeTrackDetails(track, output); output.writeLong(track.getPosition()); stream.commitMessage(TRACK_INFO_VERSIONED); }
Example #2
Source File: RequestUtils.java From andesite-node with MIT License | 5 votes |
/** * Encodes the provided track to base64. * * @param playerManager Player manager used for encoding (must have the source manager enabled). * @param track Track to encode. * * @return Base64 encoded track. */ @Nonnull @CheckReturnValue public static String trackString(@Nonnull AudioPlayerManager playerManager, @Nonnull AudioTrack track) { var baos = new ByteArrayOutputStream(); try { playerManager.encodeTrack(new MessageOutput(baos), track); } catch(IOException e) { throw new AssertionError(e); } return Base64.getEncoder().encodeToString(baos.toByteArray()); }
Example #3
Source File: LavalinkUtil.java From Lavalink-Client with MIT License | 5 votes |
/** * @param track the track to serialize * @return the serialized track as binary * @throws IOException if there is an IO problem */ @SuppressWarnings("WeakerAccess") public static byte[] toBinary(AudioTrack track) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PLAYER_MANAGER.encodeTrack(new MessageOutput(baos), track); return baos.toByteArray(); }
Example #4
Source File: JbAudioPlayerManagerImpl.java From JuniperBot with GNU General Public License v3.0 | 5 votes |
@Override public byte[] encodeTrack(AudioTrack track) { if (track == null) { return null; } try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { MessageOutput output = new MessageOutput(outputStream); encodeTrack(output, track); return outputStream.toByteArray(); } catch (IOException e) { log.warn("Could not encode track {}", track); } return null; }
Example #5
Source File: MusicController.java From lavaplayer with Apache License 2.0 | 5 votes |
@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(); }
Example #6
Source File: Util.java From Lavalink with MIT License | 4 votes |
public static String toMessage(AudioPlayerManager audioPlayerManager, AudioTrack track) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); audioPlayerManager.encodeTrack(new MessageOutput(baos), track); return Base64.encodeBase64String(baos.toByteArray()); }
Example #7
Source File: AudioPlayerManager.java From lavaplayer with Apache License 2.0 | 2 votes |
/** * Encode a track into an output stream. If the decoder is not supposed to know the number of tracks in advance, then * the encoder should call MessageOutput#finish() after all the tracks it wanted to write have been written. This will * make decodeTrack() return null at that position * * @param stream The message stream to write it to. * @param track The track to encode. * @throws IOException On IO error. */ void encodeTrack(MessageOutput stream, AudioTrack track) throws IOException;