Java Code Examples for com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager#decodeTrack()

The following examples show how to use com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager#decodeTrack() . 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: RequestUtils.java    From andesite-node with MIT License 6 votes vote down vote up
/**
 * Decodes an audio track from it's base64 representation.
 *
 * @param playerManager Player manager used for decoding (must have the source manager enabled).
 * @param base64        Base64 encoded track.
 *
 * @return The decoded track.
 */
@Nullable
@CheckReturnValue
public static AudioTrack decodeTrack(@Nonnull AudioPlayerManager playerManager, @Nonnull String base64) {
    try {
        var v = playerManager.decodeTrack(new MessageInput(new ByteArrayInputStream(
            Base64.getDecoder().decode(base64)
        )));
        return v == null ? null : v.decodedTrack;
    } catch(IOException e) {
        throw new AssertionError(e);
    }
}
 
Example 2
Source File: LavalinkTrackLoader.java    From MantaroBot with GNU General Public License v3.0 5 votes vote down vote up
private static AudioTrack decode(AudioPlayerManager manager, String track) {
    try {
        return manager.decodeTrack(new MessageInput(new ByteArrayInputStream(
                Base64.getDecoder().decode(track)
        ))).decodedTrack;
    } catch (Exception e) {
        throw new IllegalArgumentException("Failed to decode track", e);
    }
}
 
Example 3
Source File: Util.java    From Lavalink with MIT License 4 votes vote down vote up
public static AudioTrack toAudioTrack(AudioPlayerManager audioPlayerManager, String message) throws IOException {
    byte[] b64 = Base64.decodeBase64(message);
    ByteArrayInputStream bais = new ByteArrayInputStream(b64);
    return audioPlayerManager.decodeTrack(new MessageInput(bais)).decodedTrack;
}