Record Class Player
java.lang.Object
java.lang.Record
io.github.yusufsdiscordbot.yusufsdiscordcore.bot.music.backend.Player
An audio player that is capable of playing audio tracks and provides audio frames from the
currently playing track.
-
Constructor Summary
ConstructorsConstructorDescriptionPlayer(com.sedmelluq.discord.lavaplayer.player.AudioPlayer player) Creates an instance of aPlayerrecord class. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(com.sedmelluq.discord.lavaplayer.player.event.AudioEventListener listener) Add a listener to events from this player.voidcheckCleanup(long threshold) Check if the player should be "cleaned up" - stopped due to nothing using it, with the given threshold.final booleanIndicates whether some other object is "equal to" this one.com.sedmelluq.discord.lavaplayer.track.AudioTrackintfinal inthashCode()Returns a hash code value for this object.booleanisPaused()booleanvoidpause()Used to pause the player.com.sedmelluq.discord.lavaplayer.player.AudioPlayerplayer()Returns the value of theplayerrecord component.voidplayTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack track) com.sedmelluq.discord.lavaplayer.track.playback.AudioFrameprovide()com.sedmelluq.discord.lavaplayer.track.playback.AudioFramebooleanprovide(com.sedmelluq.discord.lavaplayer.track.playback.MutableAudioFrame targetFrame) booleanprovide(com.sedmelluq.discord.lavaplayer.track.playback.MutableAudioFrame targetFrame, long timeout, TimeUnit unit) voidremoveListener(com.sedmelluq.discord.lavaplayer.player.event.AudioEventListener listener) Remove an attached listener using identity comparison.voidresume()Used to resume the player.voidsetFilterFactory(com.sedmelluq.discord.lavaplayer.filter.PcmFilterFactory factory) voidsetFrameBufferDuration(Integer duration) voidbooleanstartTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack track, boolean noInterrupt) voidstop()Used to terminate the player.voidStop currently playing track.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Player
public Player(com.sedmelluq.discord.lavaplayer.player.AudioPlayer player) Creates an instance of aPlayerrecord class.- Parameters:
player- the value for theplayerrecord component
-
-
Method Details
-
getPlayingTrack
public com.sedmelluq.discord.lavaplayer.track.AudioTrack getPlayingTrack()- Returns:
- Currently playing track
-
playTrack
public void playTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack track) - Parameters:
track- The track to start playing
-
startTrack
public boolean startTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack track, boolean noInterrupt) - Parameters:
track- The track to start playing, passing null will stop the current track and return falsenoInterrupt- Whether to only start if nothing else is playing- Returns:
- True if the track was started
-
stopTrack
public void stopTrack()Stop currently playing track. -
getVolume
public int getVolume() -
setVolume
-
setFilterFactory
public void setFilterFactory(com.sedmelluq.discord.lavaplayer.filter.PcmFilterFactory factory) -
setFrameBufferDuration
-
isPaused
public boolean isPaused()- Returns:
- Whether the player is paused
-
isResumed
public boolean isResumed()- Returns:
- Whether the player is resumed.
-
pause
public void pause()Used to pause the player. -
resume
public void resume()Used to resume the player. -
stop
public void stop()Used to terminate the player. -
addListener
public void addListener(com.sedmelluq.discord.lavaplayer.player.event.AudioEventListener listener) Add a listener to events from this player.- Parameters:
listener- New listener
-
removeListener
public void removeListener(com.sedmelluq.discord.lavaplayer.player.event.AudioEventListener listener) Remove an attached listener using identity comparison.- Parameters:
listener- The listener to remove
-
checkCleanup
public void checkCleanup(long threshold) Check if the player should be "cleaned up" - stopped due to nothing using it, with the given threshold.- Parameters:
threshold- Threshold in milliseconds to use
-
provide
public com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame provide()- Returns:
- Provided frame, or null if none available
-
provide
public com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame provide(long timeout, TimeUnit unit) throws TimeoutException, InterruptedException - Parameters:
timeout- Specifies the maximum time to wait for data. Pass 0 for non-blocking mode.unit- Specifies the time unit of the maximum wait time.- Returns:
- Provided frame. In case wait time is above zero, null indicates that no data is not available at the current moment, otherwise null means the end of the track.
- Throws:
TimeoutException- When wait time is above zero, but no track info is found in that time.InterruptedException- When interrupted externally (or for seek/stop).
-
provide
public boolean provide(com.sedmelluq.discord.lavaplayer.track.playback.MutableAudioFrame targetFrame) - Parameters:
targetFrame- Frame to update with the details and data of the provided frame.- Returns:
trueif a frame was provided.
-
provide
public boolean provide(com.sedmelluq.discord.lavaplayer.track.playback.MutableAudioFrame targetFrame, long timeout, TimeUnit unit) throws TimeoutException, InterruptedException - Parameters:
targetFrame- Frame to update with the details and data of the provided frame.timeout- Timeout.unit- Time unit for the timeout value.- Returns:
trueif a frame was provided.- Throws:
TimeoutException- If no frame became available within the timeout.InterruptedException- When interrupted externally (or for seek/stop).
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
player
public com.sedmelluq.discord.lavaplayer.player.AudioPlayer player()Returns the value of theplayerrecord component.- Returns:
- the value of the
playerrecord component
-