Class Song

Description

The Song object represents a song.

iTunes assigns each song a track ID, and this is used as the primary key for songs.

Located in /music.php (line 16)


	
			
Variable Summary
string $artist_name
string $comments
string $name
string $path
integer $playCount
integer $rating
integer $size
integer $time
integer $track
integer $track_id
integer $year
Method Summary
Song Song (integer $track_id, array $song_array)
Song get_song (integer $track_id, [string $artist_key = NULL], [string $album_key = NULL])
string itunes_link ()
string name ()
string path ()
array random_tracks (the $count)
array song_arrays ()
array tracks ()
array track_ids ()
Variables
string $artist_name (line 73)

If the song is a compilation, the name of the actual artist.

  • see: artist_name()
string $comments (line 67)

Comments entered in the Get Info window.

string $name (line 37)

The title of the song.

string $path (line 26)

The relative path to the song inside the music folder.

integer $playCount (line 42)

The number of times the song has been played.

integer $rating (line 62)

The star rating on a scale of 0-100.

integer $size (line 32)

The size in kilobytes.

integer $time (line 52)

The time in seconds.

integer $track (line 47)

The track number on the album.

integer $track_id (line 21)

The primary key for the song, as assigned by iTunes.

integer $year (line 57)

The year of release.

Methods
Constructor Song (line 99)

Creates a Song object from a song array.

Don't call this constructor method directly; instead use:

Song Song (integer $track_id, array $song_array)
  • integer $track_id: the track id
  • array $song_array: an array of song info
add_time_and_size (line 282)

Adds the song's time and size to the global variables $total_time and $total_size.

This method is sent by the following to each song to compute the total time and size message.

void add_time_and_size ()
album (line 244)

Accessor for the album object.

Using the accessor method makes sure that the album object has been initialized.

Album album ()
artist (line 209)

Accessor for the artist object.

Using the accessor method makes sure that the artist has been initialized.

Artist artist ()
get_song (line 146)

Returns a Song object.

Both the artist key and the album key are optional, but including them increases performance.

Song get_song (integer $track_id, [string $artist_key = NULL], [string $album_key = NULL])
  • integer $track_id: the track id
  • string $artist_key: the artist key
  • string $album_key: the album key
itunes_link (line 266)

Returns a URL to search the iTunes Store for the song.

The search results will display all versions of the song from the artist.

  • return: a URL starting with itms://
string itunes_link ()
name (line 174)

The name of the song.

  • return: the name
string name ()
path (line 185)

The path to the music file, if it is available online.

Combines the music path set in the preferences with the song's relative path in the music folder.

  • return: the path
string path ()
random_tracks (line 324)

Returns an array of random songs.

This method is used by the Party Shuffle feature.

Sends add_time_and_size() to each of the songs.

  • return: an array of Songs
array random_tracks (the $count)
  • the $count: number of songs to return
song_arrays (line 123)

Gets an array of info for all songs.

The array contains arrays with artist and album keys, indexed by track id. For an array of Song objects, use Song::tracks() instead.

  • return: an array of song arrays, with keys 'artist' and 'album', indexed by track id
  • see: Song::tracks()
array song_arrays ()
tracks (line 294)

Returns an array of all songs, sorted by name.

This method is very slow, so only use if you really need access to all songs.

  • return: an array of Songs, indexed by track id
array tracks ()
track_ids (line 309)

Returns an array of all track ids, sorted by name.

  • return: an array of integers
array track_ids ()

Documentation generated on Sun, 12 Feb 2006 19:27:54 +0100 by phpDocumentor 1.2.3