Class AudioManagerImpl
java.lang.Object
net.dv8tion.jda.internal.managers.AudioManagerImpl
- All Implemented Interfaces:
AudioManager
-
Field Summary
FieldsFields inherited from interface net.dv8tion.jda.api.managers.AudioManager
DEFAULT_CONNECTION_TIMEOUT, LOG
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Close down the current audio connection of thisGuild
and disconnects from theAudioChannel
.void
closeAudioConnection
(ConnectionStatus reason) TheAudioChannelUnion
that JDA currently has an audio connection to.The currentConnectionStatus
.long
The currently set timeout value, in milliseconds, used when waiting for an audio connection to be established.getGuild()
Gets theGuild
instance that this AudioManager is used for.getJDA()
Gets theJDA
instance that this AudioManager is a part of.The currently setAudioReceiveHandler
.The currently setAudioSendHandler
.TheSpeakingMode
that should be used when sending audio via the providedAudioSendHandler
fromAudioManager.setSendingHandler(AudioSendHandler)
.boolean
Whether audio connections from this AudioManager automatically reconnectboolean
This can be used to find out if JDA currently has an active audio connection with aAudioChannel
.boolean
Whether connections from this AudioManager are deafened.boolean
Whether connections from this AudioManager are muted, if this istrue
packages by the registeredAudioSendHandler
will be ignored by Discord.void
openAudioConnection
(AudioChannel channel) Starts the process to create an audio connection with anAudioChannel
or, if an audio connection is already open, JDA will move the connection to the provided AudioChannel.void
setAudioConnection
(AudioConnection audioConnection) void
setAutoReconnect
(boolean shouldReconnect) Sets whether audio connections from this AudioManager should automatically reconnect or not.void
setConnectedChannel
(AudioChannel channel) void
setConnectionListener
(ConnectionListener listener) Sets theConnectionListener
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
setQueueTimeout
(long queueTimeout) void
setReceivingHandler
(AudioReceiveHandler handler) Sets theAudioReceiveHandler
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 totrue
if the current connection should be displayed as muted, this will cause theAudioSendHandler
packages to not be ignored by Discord!void
setSendingHandler
(AudioSendHandler handler) Sets theAudioSendHandler
that the manager will use to provide audio data to an audio connection.void
TheSpeakingMode
that should be used when sending audio via the providedAudioSendHandler
fromAudioManager.setSendingHandler(AudioSendHandler)
.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.dv8tion.jda.api.managers.AudioManager
setSpeakingMode
-
Field Details
-
CONNECTION_LOCK
-
-
Constructor Details
-
AudioManagerImpl
-
-
Method Details
-
getAudioConnection
-
openAudioConnection
Description copied from interface:AudioManager
Starts the process to create an audio connection with anAudioChannel
or, if an audio connection is already open, JDA will move the connection to the provided AudioChannel.
Note: Currently you can only be connected to a singleAudioChannel
perGuild
.This method will automatically move the current connection if one connection is already open in this underlying
Guild
.
Current connections can be closed withAudioManager.closeAudioConnection()
.- Specified by:
openAudioConnection
in interfaceAudioManager
- Parameters:
channel
- TheAudioChannel
to open an audio connection with.
-
closeAudioConnection
public void closeAudioConnection()Description copied from interface:AudioManager
Close down the current audio connection of thisGuild
and disconnects from theAudioChannel
.
If this is called when JDA doesn't have an audio connection, nothing happens.- Specified by:
closeAudioConnection
in interfaceAudioManager
-
closeAudioConnection
-
setSpeakingMode
Description copied from interface:AudioManager
TheSpeakingMode
that should be used when sending audio via the providedAudioSendHandler
fromAudioManager.setSendingHandler(AudioSendHandler)
. By default this will useSpeakingMode.VOICE
.
Example:EnumSet.of(SpeakingMode.PRIORITY_SPEAKER, SpeakingMode.VOICE)
- Specified by:
setSpeakingMode
in interfaceAudioManager
- Parameters:
mode
- The speaking modes- See Also:
-
getSpeakingMode
Description copied from interface:AudioManager
TheSpeakingMode
that should be used when sending audio via the providedAudioSendHandler
fromAudioManager.setSendingHandler(AudioSendHandler)
. By default this will useSpeakingMode.VOICE
.- Specified by:
getSpeakingMode
in interfaceAudioManager
- Returns:
- The current speaking mode, represented in an
EnumSet
- See Also:
-
getJDA
Description copied from interface:AudioManager
Gets theJDA
instance that this AudioManager is a part of.- Specified by:
getJDA
in interfaceAudioManager
- Returns:
- The corresponding JDA instance
-
getGuild
Description copied from interface:AudioManager
Gets theGuild
instance that this AudioManager is used for.- Specified by:
getGuild
in interfaceAudioManager
- Returns:
- The Guild that this AudioManager manages.
-
getConnectedChannel
Description copied from interface:AudioManager
TheAudioChannelUnion
that JDA currently has an audio connection to.
If JDA currently doesn't have an active audio connection, this will returnnull
.- Specified by:
getConnectedChannel
in interfaceAudioManager
- Returns:
- The
AudioChannelUnion
the audio connection is connected to, ornull
if not connected.
-
isConnected
public boolean isConnected()Description copied from interface:AudioManager
This can be used to find out if JDA currently has an active audio connection with aAudioChannel
. If this returns true, thenAudioManager.getConnectedChannel()
will return theAudioChannel
which JDA is connected to.- Specified by:
isConnected
in interfaceAudioManager
- Returns:
- True, if JDA currently has an active audio connection.
-
setConnectTimeout
public void setConnectTimeout(long timeout) Description copied from interface:AudioManager
Sets the amount of time, in milliseconds, that will be used as the timeout when waiting for the audio connection to successfully connect. The default value is 10 second (10,000 milliseconds).
Note: If you set this value to 0, you can remove timeout functionality and JDA will wait FOREVER for the connection to be established. This is no advised as it is possible that the connection may never be established.- Specified by:
setConnectTimeout
in interfaceAudioManager
- Parameters:
timeout
- The amount of time, in milliseconds, that should be waited when waiting for the audio connection to be established.
-
getConnectTimeout
public long getConnectTimeout()Description copied from interface:AudioManager
The currently set timeout value, in milliseconds, used when waiting for an audio connection to be established.- Specified by:
getConnectTimeout
in interfaceAudioManager
- Returns:
- The currently set timeout.
-
setSendingHandler
Description copied from interface:AudioManager
Sets theAudioSendHandler
that the manager will use to provide audio data to an audio connection.
The handler provided here will persist between audio connection connects 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.JDA recommends LavaPlayer as an
AudioSendHandler
. It provides a demo targeted at JDA users.- Specified by:
setSendingHandler
in interfaceAudioManager
- Parameters:
handler
- TheAudioSendHandler
used to provide audio data.
-
getSendingHandler
Description copied from interface:AudioManager
The currently setAudioSendHandler
. If there is no sender currently set, this method will returnnull
.- Specified by:
getSendingHandler
in interfaceAudioManager
- Returns:
- The currently active
AudioSendHandler
ornull
.
-
setReceivingHandler
Description copied from interface:AudioManager
Sets theAudioReceiveHandler
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.- Specified by:
setReceivingHandler
in interfaceAudioManager
- Parameters:
handler
- TheAudioReceiveHandler
used to process received audio data.
-
getReceivingHandler
Description copied from interface:AudioManager
The currently setAudioReceiveHandler
. If there is no receiver currently set, this method will returnnull
.- Specified by:
getReceivingHandler
in interfaceAudioManager
- Returns:
- The currently active
AudioReceiveHandler
ornull
.
-
setConnectionListener
Description copied from interface:AudioManager
Sets theConnectionListener
for this AudioManager. It will be informed about meta data of any audio connection established through this AudioManager. Further information can be found in theConnectionListener
documentation!- Specified by:
setConnectionListener
in interfaceAudioManager
- Parameters:
listener
- AConnectionListener
instance
-
getConnectionListener
Description copied from interface:AudioManager
- Specified by:
getConnectionListener
in interfaceAudioManager
- Returns:
- The current
ConnectionListener
instance for this AudioManager.
-
getConnectionStatus
Description copied from interface:AudioManager
The currentConnectionStatus
.
This status indicates represents the connection status of an audio connection.- Specified by:
getConnectionStatus
in interfaceAudioManager
- Returns:
- The current
ConnectionStatus
.
-
setAutoReconnect
public void setAutoReconnect(boolean shouldReconnect) Description copied from interface:AudioManager
Sets whether audio connections from this AudioManager should automatically reconnect or not. Defaulttrue
- Specified by:
setAutoReconnect
in interfaceAudioManager
- Parameters:
shouldReconnect
- Whether audio connections from this AudioManager should automatically reconnect
-
isAutoReconnect
public boolean isAutoReconnect()Description copied from interface:AudioManager
Whether audio connections from this AudioManager automatically reconnect- Specified by:
isAutoReconnect
in interfaceAudioManager
- Returns:
- Whether audio connections from this AudioManager automatically reconnect
-
setSelfMuted
public void setSelfMuted(boolean muted) Description copied from interface:AudioManager
Set this totrue
if the current connection should be displayed as muted, this will cause theAudioSendHandler
packages to not be ignored by Discord!- Specified by:
setSelfMuted
in interfaceAudioManager
- Parameters:
muted
- Whether the connection should stop sending audio and display as muted.
-
isSelfMuted
public boolean isSelfMuted()Description copied from interface:AudioManager
Whether connections from this AudioManager are muted, if this istrue
packages by the registeredAudioSendHandler
will be ignored by Discord.- Specified by:
isSelfMuted
in interfaceAudioManager
- Returns:
- Whether connections from this AudioManager are muted
-
setSelfDeafened
public void setSelfDeafened(boolean deafened) Description copied from interface:AudioManager
Sets whether connections from this AudioManager should be deafened.
This does not include being muted, that value can be set individually fromAudioManager.setSelfMuted(boolean)
and checked viaAudioManager.isSelfMuted()
- Specified by:
setSelfDeafened
in interfaceAudioManager
- Parameters:
deafened
- Whether connections from this AudioManager should be deafened.
-
isSelfDeafened
public boolean isSelfDeafened()Description copied from interface:AudioManager
Whether connections from this AudioManager are deafened.
This does not include being muted, that value can be set individually fromAudioManager.setSelfMuted(boolean)
and checked viaAudioManager.isSelfMuted()
- Specified by:
isSelfDeafened
in interfaceAudioManager
- Returns:
- True, if connections from this AudioManager are deafened
-
getListenerProxy
-
setAudioConnection
-
setConnectedChannel
-
setQueueTimeout
public void setQueueTimeout(long queueTimeout)
-