public class LavaPlayerJdaWrapper implements AudioSendHandler {
private final AudioPlayer audioPlayer;
private AudioFrame lastFrame;
public LavaPlayerJdaWrapper(AudioPlayer audioPlayer) {
this.audioPlayer = audioPlayer;
}
@Override
public boolean canProvide() {
lastFrame = audioPlayer.provide();
AudioTrack playingTrack = audioPlayer.getPlayingTrack();
System.out.printf("Playing track: %s%nLast frame data length: %s%n",
playingTrack != null ? playingTrack.getInfo().title : "N/A",
lastFrame != null ? lastFrame.getDataLength() : "N/A"
);
return lastFrame != null;
}
@Override
public ByteBuffer provide20MsAudio() {
return ByteBuffer.wrap(lastFrame.getData());
}
@Override
public boolean isOpus() {
return true;
}
}
The important thing here is canProvide(), which is continuously called to update the last audio frame, which is then played in a discord voice channel
However, when I try to queue a song using YouTube, this is printed:
...
Playing track: N/A
Last frame data length: N/A
Playing track: N/A
Last frame data length: N/A
Playing track: We Are No Saints
Last frame data length: N/A
Playing track: We Are No Saints
Last frame data length: N/A
...
My bot then immediately leaves the voice channel after joining, as if it just finished playing the song. It behaves just like the song finished normally, except nothing was actually played. I don't get any exceptions either.
For some reason, audioPlayer.provide(); seems to return null, which is expected when nothing is being played, but shouldn't happen whenever something is being played. In my case, it seems to return null regardless of if it's playing or not. audioPlayer.getPlayingTrack() is no longer null when the track starts playing, so the track should be properly queued.
The audio player uses the default implementation of AudioPlayer, aquired through new DefaultAudioPlayerManager().createPlayer(). The player is assigned a custom listener class that implements AudioEventAdapter, although I don't think this affects the audio player's unexpected behavior
The song in question is queued using the search phrase 'we are no saints blind channel "auto-generated by youtube"', which leads to this song: https://www.youtube.com/watch?v=meCKfUO6y8c. It's also worth noting that this also happens with other songs too
I have the following JDA wrapper:
The important thing here is
canProvide()
, which is continuously called to update the last audio frame, which is then played in a discord voice channel However, when I try to queue a song using YouTube, this is printed:My bot then immediately leaves the voice channel after joining, as if it just finished playing the song. It behaves just like the song finished normally, except nothing was actually played. I don't get any exceptions either.
For some reason,
audioPlayer.provide();
seems to returnnull
, which is expected when nothing is being played, but shouldn't happen whenever something is being played. In my case, it seems to returnnull
regardless of if it's playing or not.audioPlayer.getPlayingTrack()
is no longernull
when the track starts playing, so the track should be properly queued.The audio player uses the default implementation of
AudioPlayer
, aquired throughnew DefaultAudioPlayerManager().createPlayer()
. The player is assigned a custom listener class that implementsAudioEventAdapter
, although I don't think this affects the audio player's unexpected behaviorThe song in question is queued using the search phrase 'we are no saints blind channel "auto-generated by youtube"', which leads to this song: https://www.youtube.com/watch?v=meCKfUO6y8c. It's also worth noting that this also happens with other songs too