Class Track

java.lang.Object
se.michaelthelin.spotify.model_objects.AbstractModelObject
se.michaelthelin.spotify.model_objects.specification.Track
All Implemented Interfaces:
Serializable, IModelObject, ITrack, IPlaylistItem, ISearchModelObject, IArtistTrackModelObject

Retrieve information about Track objects by building instances from this class.
See Also:
  • Method Details

    • getAlbum

      public AlbumSimplified getAlbum()
      Get the album on which the track appears.
      Returns:
      The album on which the track appears. The (simplified) album object includes a link in href to full information about the album.
    • getArtists

      public ArtistSimplified[] getArtists()
      Get the artists who performed the track.
      Specified by:
      getArtists in interface ITrack
      Returns:
      The artists who performed the track. Each artist object includes a link in href to more detailed information about the artist.
    • getDiscNumber

      public Integer getDiscNumber()
      Get the disc number of the track in its album.
      Specified by:
      getDiscNumber in interface ITrack
      Returns:
      The disc number (usually 1 unless the album consists of more than one disc).
    • getDurationMs

      public Integer getDurationMs()
      Get the duration of the track in milliseconds.
      Specified by:
      getDurationMs in interface IPlaylistItem
      Returns:
      The track length in milliseconds.
    • getExplicit

      public Boolean getExplicit()
      Check whether the track is explicit or not.
      Specified by:
      getExplicit in interface ITrack
      Returns:
      Whether or not the track has explicit lyrics (true = yes it does; false = no it does not OR unknown).
    • getExternalIds

      public ExternalId getExternalIds()
      Get the external IDs of the track.
      Example: isrc -> "International Standard Recording Code".
      Returns:
      Known external IDs for the track.
    • getExternalUrls

      public ExternalUrl getExternalUrls()
      Get the external URLs of the track.
      Example: Spotify-URL.
      Specified by:
      getExternalUrls in interface IPlaylistItem
      Returns:
      Known external URLs for this track.
    • getHref

      public String getHref()
      Get the full Spotify Web API endpoint URL of the track.
      Specified by:
      getHref in interface IPlaylistItem
      Returns:
      A link to the Web API endpoint providing full details of the track.
    • getId

      public String getId()
      Get the Spotify ID of the track.
      Specified by:
      getId in interface IPlaylistItem
      Returns:
      The Spotify ID for the track.
    • getIsPlayable

      public Boolean getIsPlayable()
      Check whether the track is playable in the market, which may has been specified somewhere before requesting it. Part of the response when Track Relinking is applied.
      Specified by:
      getIsPlayable in interface ITrack
      Returns:
      If true, the track is playable in the given market. Otherwise false.
    • getRestrictions

      public Restrictions getRestrictions()
      Get the restrictions of the track. Part of the response when Track Relinking is applied, the original track is not available in the given market, and Spotify did not have any tracks to relink it with. The track response will still contain metadata for the original track, and a restrictions object containing the reason why the track is not available.
      Example: "restrictions" : {"reason" : "market"}
      Returns:
      The track response will still contain metadata for the original track, and a restrictions object containing the reason why the track is not available.
    • getName

      public String getName()
      Get the name of the track.
      Specified by:
      getName in interface IPlaylistItem
      Returns:
      Track name.
    • getPreviewUrl

      public String getPreviewUrl()
      Get a link to a 30 second preview (MP3 format) of the track. null if not available.
      Specified by:
      getPreviewUrl in interface ITrack
      Returns:
      A link to a 30 second preview (MP3 format) of the track. null if not available.
    • getTrackNumber

      public Integer getTrackNumber()
      Get the track number of the track. If an album has several discs, the track number is the number on the specified disc.
      Specified by:
      getTrackNumber in interface ITrack
      Returns:
      The number of the track.
    • getType

      public ModelObjectType getType()
      Get the model object type, which should be a "track" in this case.
      Specified by:
      getType in interface IPlaylistItem
      Returns:
      The object type: "track".
    • getUri

      public String getUri()
      Get the Spotify track URI.
      Specified by:
      getUri in interface IPlaylistItem
      Returns:
      The Spotify URI for the track.
    • toString

      public String toString()
      Description copied from class: AbstractModelObject
      Returns a String representation of this model object in the style:

      ModelObject(attr1=value1, attr2=value2, ...)

      Specified by:
      toString in class AbstractModelObject
    • builder

      public Track.Builder builder()
      Description copied from interface: IModelObject
      Create a builder for building an instance of a model object.
      The type of the builder and its methods depend on its corresponding implementation.
      Specified by:
      builder in interface IModelObject
      Returns:
      A builder object.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object