java.lang.Object
info.u_team.music_player.musicplayer.playlist.Playlist
All Implemented Interfaces:
info.u_team.music_player.lavaplayer.api.queue.ITrackQueue

public class Playlist extends Object implements info.u_team.music_player.lavaplayer.api.queue.ITrackQueue
This class represents a playlist. This list can be serialized or deserialized. After a serialization the tracks must be loaded, because only the uris are saved. IAudioTrack and IAudioTrackList can be added. Tracks can be removed. Tracks can be moved in the order. Any changes to the serializable fields are saved
  • Field Details

  • Constructor Details

    • Playlist

      public Playlist(String name)
      Create a new playlist object with a name
      Parameters:
      name - The playlist's name
  • Method Details

    • load

      public void load()
      Loads this playlist. This will go through all uris and search with ITrackSearch for the IAudioTrack and IAudioTrackList for LoadedTracks. This method is async.
    • load

      public void load(Runnable runnable)
      Loads this playlist. This will go through all uris and search with ITrackSearch for the IAudioTrack and IAudioTrackList for LoadedTracks. This method is async. This method calls the Runnable.run() method when everything is loaded and the playlist was not loaded before.
      Parameters:
      runnable - A runnable that should be executed when the playlist is loaded
    • unload

      public void unload()
      Unloads this playlist and removes all loaded tracks.
    • isLoaded

      public boolean isLoaded()
      Is this playlist loaded
      Returns:
      Playlist loaded
    • add

      public WrappedObject<String> add(info.u_team.music_player.lavaplayer.api.audio.IAudioTrack track)
      Adds an IAudioTrack to the uri list and the loaded tracks. This playlist must be loaded.
      Parameters:
      track - The track that should be added
      Returns:
      The WrappedObject with the uri as a string
    • add

      public WrappedObject<String> add(info.u_team.music_player.lavaplayer.api.audio.IAudioTrackList trackList)
      Adds an IAudioTrackList to the uri list and the loaded tracks if it has a valid uri and is not a search result. This playlist must be loaded.
      Parameters:
      trackList - The tracklist that should be added
      Returns:
      The WrappedObject with the uri as a string
    • remove

      public boolean remove(WrappedObject<String> uri)
      Removes an uri from the uri list and the loaded tracks. This playlist must be loaded.
      Parameters:
      uri - The WrappedObject with the uri as a string
      Returns:
      If the uri was removed
    • move

      public boolean move(WrappedObject<String> uri, int value)
      Move the uri and loaded track in the list up or down. This playlist must be loaded.
      Parameters:
      uri - The WrappedObject with the uri as a string
      value - Positive value to move the uri up the value, and the other way around for a negative value
      Returns:
      If move was successful
    • setName

      public void setName(String name)
      Sets the name of this playlist
      Parameters:
      name - Name
    • getName

      public String getName()
      Gets the name of this playlist
      Returns:
      Name of this playlist
    • getEntrySize

      public int getEntrySize()
      Gets the size of uri entries
      Returns:
      Size of uri entries
    • getLoadedTracks

      public Collection<LoadedTracks> getLoadedTracks()
      Gets a Collection of LoadedTracks. Should only be used if this playlist is already loaded. This collection is immutable
      Returns:
      Collection with all loaded tracks
    • isEmpty

      public boolean isEmpty()
      Returns true if the playlist is empty and don't contain any uris.
      Returns:
      true if empty
    • calculateNext

      public boolean calculateNext()
      Specified by:
      calculateNext in interface info.u_team.music_player.lavaplayer.api.queue.ITrackQueue
    • getNext

      public info.u_team.music_player.lavaplayer.api.audio.IAudioTrack getNext()
      Specified by:
      getNext in interface info.u_team.music_player.lavaplayer.api.queue.ITrackQueue
    • skip

      public boolean skip(Skip skip)
      Skip the current song in the Skip direction
      Parameters:
      skip - Should be skipped forward or backward
      Returns:
      If skip was executed
    • getFirstTrack

      public org.apache.commons.lang3.tuple.Pair<LoadedTracks,info.u_team.music_player.lavaplayer.api.audio.IAudioTrack> getFirstTrack()
      Gets the first track Pair with LoadedTracks and IAudioTrack in this playlist. Values in the pair might be null if there are no tracks.
      Returns:
      Pair of LoadedTracks and IAudioTrack. Can't be null, but elements can be null.
    • getLastTrack

      public org.apache.commons.lang3.tuple.Pair<LoadedTracks,info.u_team.music_player.lavaplayer.api.audio.IAudioTrack> getLastTrack()
      Gets the last track Pair with LoadedTracks and IAudioTrack in this playlist. Values in the pair might be null if there are no tracks.
      Returns:
      Pair of LoadedTracks and IAudioTrack. Can't be null, but elements can be null.
    • setPlayable

      public void setPlayable(LoadedTracks loadedTrack, info.u_team.music_player.lavaplayer.api.audio.IAudioTrack track)
      Sets the start LoadedTracks with the contained IAudioTrack
      Parameters:
      loadedTrack - LoadedTracks which must be in this playlist
      track - IAudioTrack which must be in the passed loadedTrack
    • setStopable

      public void setStopable()
      Sets the next track to null. So the queue if playing will then be stopped.