Class GroovesharkAPI
The class for the Grooveshark Javascript API. When the swf is embedded, it automatically creates an instance of this class as window.Grooveshark.
Example Usage:
//Would return something like "20100518.01"
window.Grooveshark.getApplicationVersion();
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
GroovesharkAPI(flashID)
|
| Method Attributes | Method Name and Description |
|---|---|
|
addAlbumByID(albumID, playOnAdd)
Add/Play songs from an album
|
|
|
Add the current song to your library. If this song is already in your library, it does nothing. Only available in APIVersion 1.4 and up.
|
|
|
addPlaylistByID(playlistID, playOnAdd)
Add/Play songs from a playlist
|
|
|
addSongByToken(token, playOnAdd)
Add/Play song from a song token
|
|
|
addSongsByID(songIDs, playOnAdd)
Add/Play songs from an array of songIDs
|
|
|
executeProtocol(protocol)
Used to provide support for extensions that pass gs:// URIs into the application.
|
|
|
Add the current song to your favorites.
|
|
|
Returns the version of the Javascript API
|
|
|
Returns the version of the client swf
|
|
|
Returns the current song and playback status
|
|
|
Returns the next song Only available in APIVersion 1.1 and up.
|
|
|
Returns the previous song Only available in APIVersion 1.1 and up.
|
|
|
Get the current volume of the player.
|
|
|
Get the Radio smile/frown vote for the current song.
|
|
|
next()
Play the next song in the current playlist.
|
|
|
pause()
Pause the current song.
|
|
|
play()
Play the current song.
|
|
|
previous()
Play the previous song in the current playlist.
|
|
|
Remove the currently playing song from the Now Playing queue. Only available in APIVersion 1.4 and up.
|
|
|
seekToPosition(volume)
Seek to a particular position in the current song. You cannot seek past where the song is currently loaded to. Only available in APIVersion 1.5 and up.
|
|
|
setSongStatusCallback(callback)
Define a callback function that should be called whenever the current song or status changes.
|
|
|
setVolume(volume)
Set the volume of the player.
|
|
|
If the current song is stopped or paused, it will play.
|
|
|
voteCurrentSong(vote)
Change the Radio smile/frown vote for the current song.
|
Method Detail
addAlbumByID(albumID, playOnAdd)
Add/Play songs from an album
- Parameters:
- {int} albumID
- The albumID of the album
- {Boolean} playOnAdd
- If true, will immediately play the given songs after adding them to the current playlist
- Returns:
- void
addCurrentSongToLibrary()
Add the current song to your library. If this song is already in your library, it does nothing. Only available in APIVersion 1.4 and up.
- Returns:
- void
addPlaylistByID(playlistID, playOnAdd)
Add/Play songs from a playlist
- Parameters:
- {int} playlistID
- The playlistID of the playlist
- {Boolean} playOnAdd
- If true, will immediately play the given songs after adding them to the current playlist
- Returns:
- void
addSongByToken(token, playOnAdd)
Add/Play song from a song token
- Parameters:
- {String} token
- Token of the song
- {Boolean} playOnAdd
- If true, will immediately play the given songs after adding them to the current playlist
- Returns:
- void
addSongsByID(songIDs, playOnAdd)
Add/Play songs from an array of songIDs
- Parameters:
- {int[]} songIDs
- Array of songIDs
- {Boolean} playOnAdd
- If true, will immediately play the given songs after adding them to the current playlist
- Returns:
- void
executeProtocol(protocol)
Used to provide support for extensions that pass gs:// URIs into the application. Only available in APIVersion 1.1 and up.
- Parameters:
- {String} protocol
- The gs:// URI
- Returns:
- void
favoriteCurrentSong()
Add the current song to your favorites. If this song is already in your favorites, it does nothing.
- Returns:
- void
{Number} getAPIVersion()
Returns the version of the Javascript API
- Returns:
- {Number} The API version
{String} getApplicationVersion()
Returns the version of the client swf
- Returns:
- {String} The revision number, in the format YYYYMMDD.RR
{Object} getCurrentSongStatus()
Returns the current song and playback status
- Returns:
- {Object} { song:Object (can be null) { songID:int, songName:String, artistID:int, artistName:String, albumID:int, albumName:String, trackNum:int, estimateDuration:Number, (in milliseconds) artURL:String calculatedDuration:Number, (in milliseconds, Only available in APIVersion 1.1 and up) position:Number, (in milliseconds, Only available in APIVersion 1.1 and up) vote:int (1 = Smile, -1 = Frown, 0 = No vote, Only available in APIVersion 1.1 and up) }, status:String (One of: "none", "loading", "playing", "paused", "buffering", "failed", "completed") }
{Object} getNextSong()
Returns the next song Only available in APIVersion 1.1 and up.
- Returns:
- {Object} (can be null) { songID:int, songName:String, artistID:int, artistName:String, albumID:int, albumName:String, trackNum:int, estimateDuration:Number, (in milliseconds) artURL:String vote:int (1 = Smile, -1 = Frown, 0 = No vote) }
{Object} getPreviousSong()
Returns the previous song Only available in APIVersion 1.1 and up.
- Returns:
- {Object} (can be null) { songID:int, songName:String, artistID:int, artistName:String, albumID:int, albumName:String, trackNum:int, estimateDuration:Number, (in milliseconds) artURL:String vote:int (1 = Smile, -1 = Frown, 0 = No vote) }
{Number} getVolume()
Get the current volume of the player. Only available in APIVersion 1.1 and up.
- Returns:
- {Number} The current volume
{int} getVoteForCurrentSong()
Get the Radio smile/frown vote for the current song. Only available in APIVersion 1.1 and up.
- Returns:
- {int} 1 = Smile, -1 = Frown, 0 = No vote
next()
Play the next song in the current playlist. If there is no next song, it will do nothing.
- Returns:
- void
pause()
Pause the current song. If no current song, or song is not playing, it will do nothing.
- Returns:
- void
play()
Play the current song. If paused, will resume, otherwise will play from the beginning. If there is no current song, it will do nothing.
- Returns:
- void
previous()
Play the previous song in the current playlist. If there is no previous song, it will do nothing.
- Returns:
- void
removeCurrentSongFromQueue()
Remove the currently playing song from the Now Playing queue. Only available in APIVersion 1.4 and up.
- Returns:
- void
seekToPosition(position)
Seek to a particular position in the current song. You cannot seek past where the song is currently loaded to. Only available in APIVersion 1.5 and up.
- Parameters:
- {Number} position
- The position to seek to, in milliseconds.
- Returns:
- void
{Object} setSongStatusCallback(callback)
Define a callback function that should be called whenever the current song or status changes. This function should expect to be passed a single parameter, an object in the same format as the return for getCurrentSongStatus. It also returns the current status.
- Parameters:
- {String} callback
- The name of the function to be used as a callback.
- Returns:
- {Object} { song:Object (can be null) { songID:int, songName:String, artistID:int, artistName:String, albumID:int, albumName:String, trackNum:int, estimateDuration:Number, (in milliseconds) artURL:String calculatedDuration:Number, (in milliseconds, Only available in APIVersion 1.1 and up) position:Number, (in milliseconds, Only available in APIVersion 1.1 and up) vote:int (1 = Smile, -1 = Frown, 0 = No vote, Only available in APIVersion 1.1 and up) }, status:String (One of: "none", "loading", "playing", "paused", "buffering", "failed", "completed") }
setVolume(volume)
Set the volume of the player. Valid values are 0 through 100.
- Parameters:
- {Number} volume
- The volume to set
- Returns:
- void
togglePlayPause()
If the current song is stopped or paused, it will play. If the current song is playing, it will pause. If there is no current song, it will do nothing.
- Returns:
- void
voteCurrentSong(vote)
Change the Radio smile/frown vote for the current song. Only works if Radio is turned on.
- Parameters:
- {int} vote
- 1 = Smile, -1 = Frown, 0 = Remove vote
- Returns:
- void