java.lang.Object
java.lang.Record
io.github.yusufsdiscordbot.yusufsdiscordcore.bot.music.backend.Player

public record Player(com.sedmelluq.discord.lavaplayer.player.AudioPlayer player) extends Record
An audio player that is capable of playing audio tracks and provides audio frames from the currently playing track.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Player(com.sedmelluq.discord.lavaplayer.player.AudioPlayer player)
    Creates an instance of a Player record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addListener(com.sedmelluq.discord.lavaplayer.player.event.AudioEventListener listener)
    Add a listener to events from this player.
    void
    checkCleanup(long threshold)
    Check if the player should be "cleaned up" - stopped due to nothing using it, with the given threshold.
    final boolean
    Indicates whether some other object is "equal to" this one.
    com.sedmelluq.discord.lavaplayer.track.AudioTrack
     
    int
     
    final int
    Returns a hash code value for this object.
    boolean
     
    boolean
     
    void
    Used to pause the player.
    com.sedmelluq.discord.lavaplayer.player.AudioPlayer
    Returns the value of the player record component.
    void
    playTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack track)
     
    com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame
     
    com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame
    provide(long timeout, TimeUnit unit)
     
    boolean
    provide(com.sedmelluq.discord.lavaplayer.track.playback.MutableAudioFrame targetFrame)
     
    boolean
    provide(com.sedmelluq.discord.lavaplayer.track.playback.MutableAudioFrame targetFrame, long timeout, TimeUnit unit)
     
    void
    removeListener(com.sedmelluq.discord.lavaplayer.player.event.AudioEventListener listener)
    Remove an attached listener using identity comparison.
    void
    Used to resume the player.
    void
    setFilterFactory(com.sedmelluq.discord.lavaplayer.filter.PcmFilterFactory factory)
     
    void
     
    void
    setVolume(@NotNull Volume volume)
     
    boolean
    startTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack track, boolean noInterrupt)
     
    void
    Used to terminate the player.
    void
    Stop currently playing track.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Player

      public Player(com.sedmelluq.discord.lavaplayer.player.AudioPlayer player)
      Creates an instance of a Player record class.
      Parameters:
      player - the value for the player record 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 false
      noInterrupt - 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

      public void setVolume(@NotNull @NotNull Volume volume)
    • setFilterFactory

      public void setFilterFactory(com.sedmelluq.discord.lavaplayer.filter.PcmFilterFactory factory)
    • setFrameBufferDuration

      public void setFrameBufferDuration(Integer duration)
    • 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:
      true if 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:
      true if a frame was provided.
      Throws:
      TimeoutException - If no frame became available within the timeout.
      InterruptedException - When interrupted externally (or for seek/stop).
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • player

      public com.sedmelluq.discord.lavaplayer.player.AudioPlayer player()
      Returns the value of the player record component.
      Returns:
      the value of the player record component