public interface AudioManager
VoiceChannels
. Also controls audio handlers.Modifier and Type | Field | Description |
---|---|---|
static long |
DEFAULT_CONNECTION_TIMEOUT |
|
static org.slf4j.Logger |
LOG |
Modifier and Type | Method | Description |
---|---|---|
void |
closeAudioConnection() |
Close down the current audio connection of this
Guild
and disconnects from the VoiceChannel . |
VoiceChannel |
getConnectedChannel() |
The
VoiceChannel that JDA currently has an audio connection
to. |
ConnectionListener |
getConnectionListener() |
|
ConnectionStatus |
getConnectionStatus() |
The current
ConnectionStatus . |
long |
getConnectTimeout() |
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() |
The currently set
AudioReceiveHandler . |
AudioSendHandler |
getSendingHandler() |
The currently set
AudioSendHandler . |
java.util.EnumSet<SpeakingMode> |
getSpeakingMode() |
The
SpeakingMode that should be used when sending audio via
the provided AudioSendHandler from setSendingHandler(AudioSendHandler) . |
boolean |
isAttemptingToConnect() |
This can be used to find out if JDA is currently attempting to setup an audio connection.
|
boolean |
isAutoReconnect() |
Whether audio connections from this AudioManager automatically reconnect
|
boolean |
isConnected() |
This can be used to find out if JDA currently has an active audio connection with a
VoiceChannel . |
boolean |
isSelfDeafened() |
Whether connections from this AudioManager are deafened.
|
boolean |
isSelfMuted() |
Whether connections from this AudioManager are muted,
if this is
true packages by the registered AudioSendHandler
will be ignored by Discord. |
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. |
void |
setAutoReconnect(boolean shouldReconnect) |
Sets whether audio connections from this AudioManager
should automatically reconnect or not.
|
void |
setConnectionListener(ConnectionListener listener) |
Sets the
ConnectionListener for this AudioManager. |
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) |
Sets whether connections from this AudioManager should be deafened.
|
void |
setSelfMuted(boolean muted) |
Set this to
true if the current connection should be displayed as muted,
this will cause the AudioSendHandler packages
to not be ignored by Discord! |
void |
setSendingHandler(AudioSendHandler handler) |
Sets the
AudioSendHandler
that the manager will use to provide audio data to an audio connection. |
void |
setSpeakingMode(java.util.Collection<SpeakingMode> mode) |
The
SpeakingMode that should be used when sending audio via
the provided AudioSendHandler from setSendingHandler(AudioSendHandler) . |
default void |
setSpeakingMode(SpeakingMode... mode) |
The
SpeakingMode that should be used when sending audio via
the provided AudioSendHandler from setSendingHandler(AudioSendHandler) . |
static final long DEFAULT_CONNECTION_TIMEOUT
static final org.slf4j.Logger 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
.
This method will automatically move the current connection if one connection is already open in this underlying Guild
.
Current connections can be closed with closeAudioConnection()
.
Client accounts can only connect to a single VoiceChannel
at once. It is an Account-Wide limitation!
channel
- The VoiceChannel
to open an audio connection with.java.lang.IllegalArgumentException
- null
.java.lang.UnsupportedOperationException
- If audio is disabled due to an internal JDA errorGuildUnavailableException
- If the Guild is temporarily unavailableInsufficientPermissionException
- VOICE_CONNECT
VOICE_MOVE_OTHERS
and the user limit
has been exceeded!void closeAudioConnection()
Guild
and disconnects from the VoiceChannel
.
@Incubating void setSpeakingMode(java.util.Collection<SpeakingMode> mode)
SpeakingMode
that should be used when sending audio via
the provided AudioSendHandler
from setSendingHandler(AudioSendHandler)
.
By default this will use SpeakingMode.VOICE
.
EnumSet.of(SpeakingMode.PRIORITY_SPEAKER, SpeakingMode.VOICE)
mode
- The speaking modesjava.lang.IllegalArgumentException
- If the provided collection is null or emptygetSpeakingMode()
,
setSpeakingMode(SpeakingMode...)
@Incubating default void setSpeakingMode(SpeakingMode... mode)
SpeakingMode
that should be used when sending audio via
the provided AudioSendHandler
from setSendingHandler(AudioSendHandler)
.
By default this will use SpeakingMode.VOICE
.mode
- The speaking modesjava.lang.IllegalArgumentException
- If the provided array is null or emptygetSpeakingMode()
@Incubating java.util.EnumSet<SpeakingMode> getSpeakingMode()
SpeakingMode
that should be used when sending audio via
the provided AudioSendHandler
from setSendingHandler(AudioSendHandler)
.
By default this will use SpeakingMode.VOICE
.EnumSet
setSpeakingMode(Collection)
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.
JDA recommends LavaPlayer
as an AudioSendHandler
.
It provides a demo targeted at JDA users.
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
for this AudioManager.
It will be informed about meta data of any audio connection established through this AudioManager.
Further information can be found in the ConnectionListener
documentation!listener
- A ConnectionListener
instanceConnectionListener getConnectionListener()
ConnectionListener
instance
for this AudioManager.ConnectionStatus getConnectionStatus()
ConnectionStatus
.
ConnectionStatus
.void setAutoReconnect(boolean shouldReconnect)
true
shouldReconnect
- Whether audio connections from this AudioManager should automatically reconnectboolean isAutoReconnect()
void setSelfMuted(boolean muted)
true
if the current connection should be displayed as muted,
this will cause the AudioSendHandler
packages
to not be ignored by Discord!muted
- Whether the connection should stop sending audio
and display as muted.boolean isSelfMuted()
true
packages by the registered AudioSendHandler
will be ignored by Discord.void setSelfDeafened(boolean deafened)
setSelfMuted(boolean)
and checked via isSelfMuted()
deafened
- Whether connections from this AudioManager should be deafened.boolean isSelfDeafened()
setSelfMuted(boolean)
and checked via isSelfMuted()