Closed FlashOnFire closed 6 years ago
Take a look at this
public static AudioTrack toAudioTrack(String message) throws IOException {
byte[] b64 = Base64.decodeBase64(message);
ByteArrayInputStream bais = new ByteArrayInputStream(b64);
return Player.PLAYER_MANAGER.decodeTrack(new MessageInput(bais)).decodedTrack;
}
public static String toMessage(AudioTrack track) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Player.PLAYER_MANAGER.encodeTrack(new MessageOutput(baos), track);
return Base64.encodeBase64String(baos.toByteArray());
}
Thanks, I'll give it a try now
It works, thanks a lot @Frederikam !
:+1:
Hi,
I have a similar issue because with this kind of transfer, I can't play some mp3 files. Here's the stack trace :
[lava-daemon-pool-playback-1-thread-10] ERROR com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor - Error in playback of C:\Users\FlashOnFire\Desktop\JingleEmission.mp3
com.sedmelluq.discord.lavaplayer.tools.FriendlyException: Something broke when playing the track.
at com.sedmelluq.discord.lavaplayer.tools.ExceptionTools.wrapUnfriendlyExceptions(ExceptionTools.java:40)
at com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor.execute(LocalAudioTrackExecutor.java:102)
at com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager.lambda$executeTrack$1(DefaultAudioPlayerManager.java:348)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: C:\Users\FlashOnFire\Desktop\JingleEmission.mp3 (No such file or directory)
at com.sedmelluq.discord.lavaplayer.source.local.LocalSeekableInputStream.<init>(LocalSeekableInputStream.java:36)
at com.sedmelluq.discord.lavaplayer.source.local.LocalAudioTrack.process(LocalAudioTrack.java:43)
at com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor.execute(LocalAudioTrackExecutor.java:90)
... 4 more
Caused by: java.io.FileNotFoundException: C:\Users\FlashOnFire\Desktop\JingleEmission.mp3 (No such file or directory)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at com.sedmelluq.discord.lavaplayer.source.local.LocalSeekableInputStream.<init>(LocalSeekableInputStream.java:32)
... 6 more
com.sedmelluq.discord.lavaplayer.tools.FriendlyException: Something broke when playing the track.
at com.sedmelluq.discord.lavaplayer.tools.ExceptionTools.wrapUnfriendlyExceptions(ExceptionTools.java:40)
at com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor.execute(LocalAudioTrackExecutor.java:102)
at com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager.lambda$executeTrack$1(DefaultAudioPlayerManager.java:348)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: C:\Users\FlashOnFire\Desktop\JingleEmission.mp3 (No such file or directory)
at com.sedmelluq.discord.lavaplayer.source.local.LocalSeekableInputStream.<init>(LocalSeekableInputStream.java:36)
at com.sedmelluq.discord.lavaplayer.source.local.LocalAudioTrack.process(LocalAudioTrack.java:43)
at com.sedmelluq.discord.lavaplayer.track.playback.LocalAudioTrackExecutor.execute(LocalAudioTrackExecutor.java:90)
... 4 more
The machine you're trying to play it on doesn't have that file at that location. The serialized AudioTrack
doesn't contain the file itself.
How can I do then ?
Plenty of ways:
This is not really related to Lavaplayer anymore since it is not meant to be and will not be an implementation of rysnc
.
Okay, thanks for your help !
Hello, I want to transfer a AudioTrack with an RMI setup but the object AudioTrack isn't Serializable. Can you make it implements Serializable please ?