Package MediaPlayer

Class Song

  • All Implemented Interfaces:
    java.lang.Comparable<Song>

    public class Song
    extends java.lang.Object
    implements java.lang.Comparable<Song>
    Represents a song with basic metadata information.
    • Constructor Summary

      Constructors 
      Constructor Description
      Song​(java.lang.String title, java.lang.String artist, java.lang.String album, java.lang.String duration)
      Creates a new Song with the given attributes.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(Song other)  
      java.lang.String getAlbum()  
      java.lang.String getArtist()  
      java.lang.String getDuration()  
      java.lang.String getTitle()  
      java.lang.Object[] toPlaylistRow​(int position)
      Converts the song data to an array for playlist table display.
      java.lang.String toString()  
      java.lang.Object[] toTableRow()
      Converts the song data to an array for database table display.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Song

        public Song​(java.lang.String title,
                    java.lang.String artist,
                    java.lang.String album,
                    java.lang.String duration)
        Creates a new Song with the given attributes.
        Parameters:
        title - The title of the song
        artist - The artist who performed the song
        album - The album the song belongs to
        duration - The duration of the song in MM:SS format
    • Method Detail

      • getTitle

        public java.lang.String getTitle()
        Returns:
        The title of the song
      • getArtist

        public java.lang.String getArtist()
        Returns:
        The artist of the song
      • getAlbum

        public java.lang.String getAlbum()
        Returns:
        The album of the song
      • getDuration

        public java.lang.String getDuration()
        Returns:
        The duration of the song
      • toTableRow

        public java.lang.Object[] toTableRow()
        Converts the song data to an array for database table display.
        Returns:
        Object array with [title, artist, album, duration]
      • toPlaylistRow

        public java.lang.Object[] toPlaylistRow​(int position)
        Converts the song data to an array for playlist table display.
        Parameters:
        position - The position of the song in the playlist
        Returns:
        Object array with [position, title, artist, duration]
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • compareTo

        public int compareTo​(Song other)
        Specified by:
        compareTo in interface java.lang.Comparable<Song>