public class AudioManager
extends java.lang.Object
VoiceChannels
. Also controls audio handlers.Modifier and Type | Field and Description |
---|---|
static boolean |
AUDIO_SUPPORTED |
static java.lang.String |
OPUS_LIB_NAME |
Constructor and Description |
---|
AudioManager(JDAImpl api) |
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. |
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. |
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 |
isConnected()
This can be used to find out if JDA currently has an active audio connection with a
VoiceChannel . |
void |
moveAudioConnection(VoiceChannel channel)
Moves the audio connection from one
VoiceChannel to a different
VoiceChannel . |
void |
openAudioConnection(VoiceChannel channel)
Starts the process to create an audio connection with a
VoiceChannel .Note: Currently you can only be connected to a single VoiceChannel
at a time. |
void |
setAudioConnection(AudioConnection audioConnection)
Please don't touch this method.
|
void |
setReceivingHandler(AudioReceiveHandler handler)
Sets the
AudioReceiveHandler
that the manager will use to process audio data received from an audio connection. |
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. |
public static final boolean AUDIO_SUPPORTED
public static final java.lang.String OPUS_LIB_NAME
public AudioManager(JDAImpl api)
public void openAudioConnection(VoiceChannel channel)
VoiceChannel
.VoiceChannel
at a time.channel
- The VoiceChannel
to open an audio connection with.java.lang.IllegalStateException
- If JDA is already has an active audio connection with a VoiceChannel
this will be thrown. JDA can only have 1 audio connection at a time.isAttemptingToConnect()
and isConnected()
is advised.java.lang.UnsupportedOperationException
- If AUDIO_SUPPORTED
is false due to a problem when JDA initially set up the
audio system then this will be thrown.AudioManager.AUDIO_SUPPORTED
first.public void moveAudioConnection(VoiceChannel channel)
VoiceChannel
to a different
VoiceChannel
. The destination channel MUST be in the same
Guild
as VoiceChannel
that
the audio connection is currently connected to.channel
- The destination VoiceChannel
to which the audio connection
will move to.java.lang.IllegalStateException
- If there is no open audio connection.java.lang.IllegalArgumentException
- null
.public void closeAudioConnection()
VoiceChannel
.public JDA getJDA()
JDA
instance that this AudioManager is a part of.public boolean isAttemptingToConnect()
getQueuedAudioConnection()
will return the
VoiceChannel
that JDA is attempting to setup an audio connection to.public 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.public 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.public boolean isConnected()
VoiceChannel
. If this returns true, then
getConnectedChannel()
will return the VoiceChannel
which
JDA is connected to.public void setAudioConnection(AudioConnection audioConnection)
openAudioConnection(net.dv8tion.jda.entities.VoiceChannel)
audioConnection
- The audio connection to deal with. Once again, don't use this method ;_;public 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.public 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.