Alex
Alex

Reputation: 153

Using the Streampad API to pull the current song title

I can't figure out how to pull the song title from the Streampad API. This is straight from the Streampad API website.

SPAPI.song():Object

Returns the current song that is playing. Object will have these properties: songTitle, artist, album, imageUrl (link to album cover art), sourceUrl (link to page containing song), queue (number this song is in the play queue).

using jQuery so far I have this..

$(".artist").click(function(){
    alert(SPAPI.song(songTitle));
});

Upvotes: 0

Views: 592

Answers (2)

Nick Craver
Nick Craver

Reputation: 630587

.songTitle is a property on the returned object, so it's accessed like this:

$(".artist").click(function(){
    alert(SPAPI.song().songTitle);
});

For a bit of error checking, make sure there is a song, like this:

$(".artist").click(function(){
    var s = SPAPI.song();
    alert(s && s.songTitle);
});

Upvotes: 1

Cristian Sanchez
Cristian Sanchez

Reputation: 32157

$(".artist").click(function(){
   alert(SPAPI.song().songTitle);
});

Upvotes: 0

Related Questions