public interface AudioManager
VoiceChannels
. Also controls audio handlers.Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_CONNECTION_TIMEOUT |
static SimpleLog |
LOG |
Modifier and Type | Method and Description |
---|---|
void |
closeAudioConnection()
Used to close down the audio connection and disconnect from the
VoiceChannel .As a note, if this is called when JDA doesn't have an audio connection, nothing happens. |
VoiceChannel |
getConnectedChannel()
Returns the
VoiceChannel that JDA currently has an audio connection
to. |
ConnectionListener |
getConnectionListener() |
ConnectionStatus |
getConnectionStatus() |
long |
getConnectTimeout()
Returns the currently set timeout value, in milliseconds, used when waiting for an audio connection to be established.
|
Guild |
getGuild()
Gets the
Guild instance that this AudioManager is used for. |
JDA |
getJDA()
Gets the
JDA instance that this AudioManager is a part of. |
VoiceChannel |
getQueuedAudioConnection()
This can be used to find out what
VoiceChannel JDA is currently
attempting to setup an audio connection for. |
AudioReceiveHandler |
getReceiveHandler()
Returns the currently set
AudioReceiveHandler . |
AudioSendHandler |
getSendingHandler()
Returns the currently set
AudioSendHandler . |
boolean |
isAttemptingToConnect()
This can be used to find out if JDA is currently attempting to setup an audio connection.
If this returns true then getQueuedAudioConnection() will return the
VoiceChannel that JDA is attempting to setup an audio connection to. |
boolean |
isAutoReconnect() |
boolean |
isConnected()
This can be used to find out if JDA currently has an active audio connection with a
VoiceChannel . |
boolean |
isSelfDeafened() |
boolean |
isSelfMuted() |
void |
openAudioConnection(VoiceChannel channel)
Starts the process to create an audio connection with a
VoiceChannel
or, if an audio connection is already open, JDA will move the connection to the provided VoiceChannel.Note: Currently you can only be connected to a single VoiceChannel
per Guild . |
void |
setAutoReconnect(boolean shouldReconnect) |
void |
setConnectionListener(ConnectionListener listener) |
void |
setConnectTimeout(long timeout)
Sets the amount of time, in milliseconds, that will be used as the timeout when waiting for the audio connection
to successfully connect.
|
void |
setReceivingHandler(AudioReceiveHandler handler)
Sets the
AudioReceiveHandler
that the manager will use to process audio data received from an audio connection. |
void |
setSelfDeafened(boolean deafened) |
void |
setSelfMuted(boolean muted) |
void |
setSendingHandler(AudioSendHandler handler)
Sets the
AudioSendHandler
that the manager will use to provide audio data to an audio connection.The handler provided here will persist between audio connection connect and disconnects. |
static final long DEFAULT_CONNECTION_TIMEOUT
static final SimpleLog LOG
void openAudioConnection(VoiceChannel channel)
VoiceChannel
or, if an audio connection is already open, JDA will move the connection to the provided VoiceChannel.VoiceChannel
per Guild
.channel
- The VoiceChannel
to open an audio connection with.java.lang.IllegalArgumentException
- null
.java.lang.IllegalStateException
- This will be thrown if JDA is currently attempting to setup an audio connection.isAttemptingToConnect()
is advised.void closeAudioConnection()
VoiceChannel
.JDA getJDA()
JDA
instance that this AudioManager is a part of.Guild getGuild()
Guild
instance that this AudioManager is used for.boolean isAttemptingToConnect()
getQueuedAudioConnection()
will return the
VoiceChannel
that JDA is attempting to setup an audio connection to.VoiceChannel getQueuedAudioConnection()
VoiceChannel
JDA is currently
attempting to setup an audio connection for. If JDA isn't trying to create an audio connection this will return
null.VoiceChannel
use isConnected()
VoiceChannel
that JDA is attempting to create an
audio connection with, or null if JDA isn't attempting to create a connection.VoiceChannel getConnectedChannel()
VoiceChannel
that JDA currently has an audio connection
to. If JDA currently doesn't have an audio connection to a VoiceChannel
this will return null.VoiceChannel
the audio connection is connected to
or null
if not connected.boolean isConnected()
VoiceChannel
. If this returns true, then
getConnectedChannel()
will return the VoiceChannel
which
JDA is connected to.void setConnectTimeout(long timeout)
timeout
- The amount of time, in milliseconds, that should be waited when waiting for the audio connection
to be established.long getConnectTimeout()
void setSendingHandler(AudioSendHandler handler)
AudioSendHandler
that the manager will use to provide audio data to an audio connection.
Example implementations of an AudioSendHandler
can be seen in the
abstract class Player
and its subclasses
FilePlayer
and URLPlayer
.
handler
- The AudioSendHandler
used to provide audio data.AudioSendHandler getSendingHandler()
AudioSendHandler
. If there is
no sender currently set, this method will return null.AudioSendHandler
or null
.void setReceivingHandler(AudioReceiveHandler handler)
AudioReceiveHandler
that the manager will use to process audio data received from an audio connection.
The handler provided here will persist between audio connection connect and disconnects. Furthermore, you don't
need to have an audio connection to set a handler. When JDA sets up a new audio connection it will use the
handler provided here.
Setting this to null will remove the audio handler.
handler
- The AudioReceiveHandler
used to process
received audio data.AudioReceiveHandler getReceiveHandler()
AudioReceiveHandler
. If there is
no receiver currently set, this method will return null.AudioReceiveHandler
or null
.void setConnectionListener(ConnectionListener listener)
ConnectionListener getConnectionListener()
ConnectionStatus getConnectionStatus()
void setAutoReconnect(boolean shouldReconnect)
boolean isAutoReconnect()
void setSelfMuted(boolean muted)
boolean isSelfMuted()
void setSelfDeafened(boolean deafened)
boolean isSelfDeafened()