Resolve mute bug
This commit is contained in:
parent
7cb4eee1ff
commit
a00c054453
@ -2,6 +2,7 @@ package net.Broken.audio;
|
||||
|
||||
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
|
||||
import com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame;
|
||||
import com.sedmelluq.discord.lavaplayer.track.playback.MutableAudioFrame;
|
||||
import net.dv8tion.jda.api.audio.AudioSendHandler;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
@ -13,27 +14,27 @@ import java.nio.ByteBuffer;
|
||||
*/
|
||||
public class AudioPlayerSendHandler implements AudioSendHandler {
|
||||
private final AudioPlayer audioPlayer;
|
||||
private AudioFrame lastFrame;
|
||||
private final ByteBuffer buffer;
|
||||
private final MutableAudioFrame frame;
|
||||
|
||||
/**
|
||||
* @param audioPlayer Audio player to wrap.
|
||||
*/
|
||||
public AudioPlayerSendHandler(AudioPlayer audioPlayer) {
|
||||
this.audioPlayer = audioPlayer;
|
||||
this.buffer = ByteBuffer.allocate(1024);
|
||||
this.frame = new MutableAudioFrame();
|
||||
this.frame.setBuffer(buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvide() {
|
||||
if (lastFrame == null) {
|
||||
lastFrame = audioPlayer.provide();
|
||||
}
|
||||
|
||||
return lastFrame != null;
|
||||
return audioPlayer.provide(frame);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer provide20MsAudio() {
|
||||
return ByteBuffer.wrap(lastFrame.getData());
|
||||
return (ByteBuffer) buffer.flip();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user