The Player API is a Flash module for your site that allows you to easily add a music player to your website. You must have streaming access on the Grooveshark API to be able to use APIPlayer.
It can be found at http://grooveshark.com/APIPlayer.swf and once embedded into the page, you can control it via JavaScript.
You control APIPlayer by using various Javascript methods.
playStreamKey(streamKey, serverHostname, serverID)
Using the Streaming API, get a streamKey, serverHostname and serverID from getStreamKeyStreamServer. Then use them to play the song in APIPlayer.
Example Return from getStreamKeyStreamServer:
{
"header":"hostname":"RHL072"},
"result":"StreamKey":"49f96f87d901402998409bcc616cffec802e8c819_4dc072cd_1a8c758_1d2b5ce_19f7ebe3_8",
"url":"http:\/\/stream57-he.grooveshark.com\/stream.php?streamKey=49f96f87d901402998409bcc616cffec802e8c819_4dc072cd_1a8c758_1d2b5ce_19f7ebe3_8",
"StreamServerID":32768,"uSecs":220000000}
}
The streamKey would be: 49f96f87d901402998409bcc616cffec802e8c819_4dc072cd_1a8c758_1d2b5ce_19f7ebe3_8
The serverHostname would be: stream57-he.grooveshark.com
The serverID would be 32768.
setSongCompleteCallback(callback)
The callback is called when the song is complete. The callback is just called and nothing is sent.
setErrorCallback(callback)
The callback is called when there is an error when playing a stream. The callback is called with a human-readable error string as the only param.
setStatusCallback(callback)
The callback is called when the status of the song changes. The callback is sent a string with a new status of the song. The string can be one of: none, loading, playing, paused, buffering, failed, completed.
The callback is called when the position of the song changes. The callback is sent an object with two keys. There is the position key and the duration key. Each have a value of an int in milliseconds.
Each of these methods can be used to pause, resume and stop (respectably) the currently playing stream. No params are needed.
This method takes a 0-100 integer value and changes the volume of the player to the corresponding value.