Song Objects

An array of JSON song objects is required by Amplitude.js. This directs AmplitudeJS to the metadata and information necessary for playing the audio.

A basic song object has the following keys:

  • name = The name of the song
  • artist = The song's artist
  • album = The song's album ( Also used to determine album changes in an environment where multiple albums are used on the page)
  • url = The URL to the song. This is most imporatant. (Soundcloud URLs discussed later)
  • cover_art_url = The URL to the song's cover art.
  • live = Set to true for a URL that is a live audio source.

The only actualy required key is the url so Amplitude.js can play the song.

As of Amplitude 3.0, the song object can include any number of keys which can be displayed anywhere on the page. You can make up a key name if you want like

	{
		"name": "Song Name 3",
		"artist": "Artist Name",
		"album": "Album Name",
		"url": "/song/url.mp3",
		"cover_art_url": "/cover/art/url.jpg",
		"made_up_key": "I'm made up completely"
	}

and reference it anywhere on your page using the 'amplitude-song-info' attribute on the element you want to display the data like:

	<span class="made-up-key" amplitude-song-info="made_up_key" amplitude-main-song-info="true"></span>

It is important to note that in multiple song environments, the order that you list the songs makes a difference. When utilizing next and previous functionality, Amplitude.js will iterate over the songs object and go to the next song or the previous song in the list. If you are using AmplitudeJS in a playlist type environment, you will define the order of the songs in the playlist by their individual indexes.

It is also important to note how songs are indexed. Like in almost all programming, indexes start at 0. So when you are setting up multiple play/pause functions or song status sliders that relate to an individual song or playlists, the indexes are used. For example, the song above named "Song Name 1" would have an index of 0, "Song Name 2" would have an index of 1, and so on.