Class PlayerManager
java.lang.Object
io.github.yusufsdiscordbot.yusufsdiscordcore.bot.music.backend.PlayerManager
-
Constructor Summary
ConstructorsConstructorDescriptionPlayerManager(com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager manager) -
Method Summary
Modifier and TypeMethodDescription@NotNull Playercom.sedmelluq.discord.lavaplayer.track.DecodedTrackHolderdecodeTrack(com.sedmelluq.discord.lavaplayer.tools.io.MessageInput stream) Decode a track from an input stream.voidEnable reporting GC pause length statistics to log (warn level with lengths bad for latency, debug level otherwise)voidencodeTrack(com.sedmelluq.discord.lavaplayer.tools.io.MessageOutput stream, com.sedmelluq.discord.lavaplayer.track.AudioTrack track) Encode a track into an output stream.com.sedmelluq.discord.lavaplayer.player.AudioConfigurationintcom.sedmelluq.discord.lavaplayer.player.AudioPlayerManagercom.sedmelluq.discord.lavaplayer.remote.RemoteNodeRegistrybooleanSeek ghosting is the effect where while a seek is in progress, buffered audio from the previous location will be served until seek is ready or the buffer is empty.loadItem(com.sedmelluq.discord.lavaplayer.track.AudioReference reference, com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler resultHandler) Schedules loading a track or playlist with the specified identifier.loadItem(String identifier, com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler resultHandler) Schedules loading a track or playlist with the specified identifier.loadItemOrdered(Object orderingKey, com.sedmelluq.discord.lavaplayer.track.AudioReference reference, com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler resultHandler) Schedules loading a track or playlist with the specified identifier with an ordering key so that items with the same ordering key are handled sequentially in the order of calls to this method.loadItemOrdered(Object orderingKey, String identifier, com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler resultHandler) Schedules loading a track or playlist with the specified identifier with an ordering key so that items with the same ordering key are handled sequentially in the order of calls to this method.voidregisterSourceManager(com.sedmelluq.discord.lavaplayer.source.AudioSourceManager sourceManager) voidsetFrameBufferDuration(int frameBufferDuration) voidsetHttpBuilderConfigurator(Consumer<org.apache.http.impl.client.HttpClientBuilder> configurator) voidsetHttpRequestConfigurator(UnaryOperator<org.apache.http.client.config.RequestConfig> configurator) voidsetItemLoaderThreadPoolSize(int poolSize) Sets the number of threads used for loading processing item load requests.voidsetPlayerCleanupThreshold(long cleanupThreshold) Sets the threshold for clearing an audio player when it has not been queried for the specified amount of time.voidsetTrackStuckThreshold(long trackStuckThreshold) Sets the threshold for how long a track can be stuck until the TrackStuckEvent is sent out.voidsetUseSeekGhosting(boolean useSeekGhosting) voidshutdown()Shut down the manager.<T extends com.sedmelluq.discord.lavaplayer.source.AudioSourceManager>
TShortcut for accessing a source manager of a certain class.voiduseRemoteNodes(String... nodeAddresses) Configure to use remote nodes for playback.
-
Constructor Details
-
PlayerManager
public PlayerManager(com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager manager)
-
-
Method Details
-
getManager
public com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager getManager() -
shutdown
public void shutdown()Shut down the manager. All threads will be stopped, the manager cannot be used any further. All players created with this manager will stop and all source managers registered to this manager will also be shut down.Every thread created by the audio manager is a daemon thread, so calling this is not required for an application to be able to gracefully shut down, however it should be called if the application continues without requiring this manager any longer.
-
useRemoteNodes
Configure to use remote nodes for playback. On consecutive calls, the connections with previously used nodes will be severed and all remotely playing tracks will be stopped first.- Parameters:
nodeAddresses- The addresses of the remote nodes
-
enableGcMonitoring
public void enableGcMonitoring()Enable reporting GC pause length statistics to log (warn level with lengths bad for latency, debug level otherwise) -
registerSourceManager
public void registerSourceManager(com.sedmelluq.discord.lavaplayer.source.AudioSourceManager sourceManager) - Parameters:
sourceManager- The source manager to register, which will be used for subsequent loadItem calls
-
source
public <T extends com.sedmelluq.discord.lavaplayer.source.AudioSourceManager> T source(Class<T> klass) Shortcut for accessing a source manager of a certain class.- Parameters:
klass- The class of the source manager to return.- Returns:
- The source manager of the specified class, or null if not registered.
-
loadItem
public Future<Void> loadItem(String identifier, com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler resultHandler) Schedules loading a track or playlist with the specified identifier.- Parameters:
identifier- The identifier that a specific source manager should be able to find the track with.resultHandler- A handler to process the result of this operation. It can either end by finding a track, finding a playlist, finding nothing or terminating with an exception.- Returns:
- A future for this operation
- See Also:
-
loadItem
public Future<Void> loadItem(com.sedmelluq.discord.lavaplayer.track.AudioReference reference, com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler resultHandler) Schedules loading a track or playlist with the specified identifier.- Parameters:
reference- The audio reference that holds the identifier that a specific source manager should be able to find the track with.resultHandler- A handler to process the result of this operation. It can either end by finding a track, finding a playlist, finding nothing or terminating with an exception.- Returns:
- A future for this operation
-
loadItemOrdered
public Future<Void> loadItemOrdered(Object orderingKey, String identifier, com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler resultHandler) Schedules loading a track or playlist with the specified identifier with an ordering key so that items with the same ordering key are handled sequentially in the order of calls to this method.- Parameters:
orderingKey- Object to use as the key for the ordering channelidentifier- The identifier that a specific source manager should be able to find the track with.resultHandler- A handler to process the result of this operation. It can either end by finding a track, finding a playlist, finding nothing or terminating with an exception.- Returns:
- A future for this operation
- See Also:
-
loadItemOrdered
public Future<Void> loadItemOrdered(Object orderingKey, com.sedmelluq.discord.lavaplayer.track.AudioReference reference, com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler resultHandler) Schedules loading a track or playlist with the specified identifier with an ordering key so that items with the same ordering key are handled sequentially in the order of calls to this method.- Parameters:
orderingKey- Object to use as the key for the ordering channelreference- The audio reference that holds the identifier that a specific source manager should be able to find the track with.resultHandler- A handler to process the result of this operation. It can either end by finding a track, finding a playlist, finding nothing or terminating with an exception.- Returns:
- A future for this operation
- See Also:
-
encodeTrack
public void encodeTrack(com.sedmelluq.discord.lavaplayer.tools.io.MessageOutput stream, com.sedmelluq.discord.lavaplayer.track.AudioTrack track) throws IOException Encode a track into an output stream. If the decoder is not supposed to know the number of tracks in advance, then the encoder should call MessageOutput#finish() after all the tracks it wanted to write have been written. This will make decodeTrack() return null at that position- Parameters:
stream- The message stream to write it to.track- The track to encode.- Throws:
IOException- On IO error.
-
decodeTrack
public com.sedmelluq.discord.lavaplayer.track.DecodedTrackHolder decodeTrack(com.sedmelluq.discord.lavaplayer.tools.io.MessageInput stream) throws IOException Decode a track from an input stream. Null returns value indicates reaching the position where the decoder had called MessageOutput#finish().- Parameters:
stream- The message stream to read it from.- Returns:
- Holder containing the track if it was successfully decoded.
- Throws:
IOException- On IO error.
-
getConfiguration
public com.sedmelluq.discord.lavaplayer.player.AudioConfiguration getConfiguration()- Returns:
- Audio processing configuration used for tracks executed by this manager.
-
isUsingSeekGhosting
public boolean isUsingSeekGhosting()Seek ghosting is the effect where while a seek is in progress, buffered audio from the previous location will be served until seek is ready or the buffer is empty.- Returns:
- True if seek ghosting is enabled.
-
setUseSeekGhosting
public void setUseSeekGhosting(boolean useSeekGhosting) - Parameters:
useSeekGhosting- The new state of seek ghosting
-
getFrameBufferDuration
public int getFrameBufferDuration()- Returns:
- The length of the internal buffer for audio in milliseconds.
-
setFrameBufferDuration
public void setFrameBufferDuration(int frameBufferDuration) - Parameters:
frameBufferDuration- New length of the internal buffer for audio in milliseconds.
-
setTrackStuckThreshold
public void setTrackStuckThreshold(long trackStuckThreshold) Sets the threshold for how long a track can be stuck until the TrackStuckEvent is sent out. A track is considered to be stuck if the player receives requests for audio samples from the track, but the audio frame provider of that track has been returning no data for the specified time.- Parameters:
trackStuckThreshold- The threshold in milliseconds.
-
setPlayerCleanupThreshold
public void setPlayerCleanupThreshold(long cleanupThreshold) Sets the threshold for clearing an audio player when it has not been queried for the specified amount of time.- Parameters:
cleanupThreshold- The threshold in milliseconds.
-
setItemLoaderThreadPoolSize
public void setItemLoaderThreadPoolSize(int poolSize) Sets the number of threads used for loading processing item load requests.- Parameters:
poolSize- Maximum number of concurrent threads used for loading items.
-
createPlayer
- Returns:
- New audio player.
-
getRemoteNodeRegistry
public com.sedmelluq.discord.lavaplayer.remote.RemoteNodeRegistry getRemoteNodeRegistry()- Returns:
- Registry of remote nodes currently used.
-
setHttpRequestConfigurator
public void setHttpRequestConfigurator(UnaryOperator<org.apache.http.client.config.RequestConfig> configurator) - Parameters:
configurator- Function used to reconfigure the request config of all sources which perform HTTP requests. Applied to all current and future registered sources. Setting this while sources are already in use will close all active connections, so this should be called before the sources have been used.
-
setHttpBuilderConfigurator
public void setHttpBuilderConfigurator(Consumer<org.apache.http.impl.client.HttpClientBuilder> configurator) - Parameters:
configurator- Function used to reconfigure the HTTP builder of all sources which perform HTTP requests. Applied to all current and future registered sources. Setting this while sources are already in use will close all active connections, so this should be called before the sources have been used.
-