aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/soundbot/AudioPlayerSendHandler.java
diff options
context:
space:
mode:
authorBrandon <bwaggone@umich.edu>2018-04-07 17:09:12 -0400
committerBrandon <bwaggone@umich.edu>2018-04-07 17:09:12 -0400
commit7eeb97fc307257290acfbf6ecbb055cdc5788c2b (patch)
tree4104b270ee87cde8a383cfc91ba6562f45dfe85e /src/main/java/soundbot/AudioPlayerSendHandler.java
parent3799c7828ad8ef2968f39e4044db36885aec1ab4 (diff)
downloadSoundChan-7eeb97fc307257290acfbf6ecbb055cdc5788c2b.tar.gz
SoundChan-7eeb97fc307257290acfbf6ecbb055cdc5788c2b.tar.bz2
SoundChan-7eeb97fc307257290acfbf6ecbb055cdc5788c2b.zip
Rename main, add properties loading
Diffstat (limited to 'src/main/java/soundbot/AudioPlayerSendHandler.java')
-rw-r--r--src/main/java/soundbot/AudioPlayerSendHandler.java48
1 files changed, 0 insertions, 48 deletions
diff --git a/src/main/java/soundbot/AudioPlayerSendHandler.java b/src/main/java/soundbot/AudioPlayerSendHandler.java
deleted file mode 100644
index 6499aad..0000000
--- a/src/main/java/soundbot/AudioPlayerSendHandler.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package soundbot;
-
-import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
-import com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame;
-import net.dv8tion.jda.core.audio.AudioSendHandler;
-
-/**
- * This is a wrapper around AudioPlayer which makes it behave as an AudioSendHandler for JDA. As JDA calls canProvide
- * before every call to provide20MsAudio(), we pull the frame in canProvide() and use the frame we already pulled in
- * provide20MsAudio().
- */
-public class AudioPlayerSendHandler implements AudioSendHandler {
- private final AudioPlayer audioPlayer;
- private AudioFrame lastFrame;
-
- /**
- * @param audioPlayer Audio player to wrap.
- */
- public AudioPlayerSendHandler(AudioPlayer audioPlayer) {
- this.audioPlayer = audioPlayer;
- }
-
- @Override
- public boolean canProvide() {
- if (lastFrame == null) {
- lastFrame = audioPlayer.provide();
- }
-
- return lastFrame != null;
- }
-
- @Override
- public byte[] provide20MsAudio() {
- if (lastFrame == null) {
- lastFrame = audioPlayer.provide();
- }
-
- byte[] data = lastFrame != null ? lastFrame.data : null;
- lastFrame = null;
-
- return data;
- }
-
- @Override
- public boolean isOpus() {
- return true;
- }
-}