views:

22

answers:

2

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));
});
A: 
$(".artist").click(function(){
   alert(SPAPI.song().songTitle);
});
CD Sanchez
+1  A: 

.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);
});
Nick Craver
We submitted within <1 second of each other. I guess you get it for the extra explanation :).
CD Sanchez