First of all, you need to instanciate the player:
var crescendo = $('#my-player').crescendo(options);
Here are the default option's value:
var options = {
autoPlay: false,
volume: 70,
endPoint: 'crescendo.html', // the player template
buttons: {
play: true,
stop: true,
loop: false,
volume: true
}
};
Load a song in crescendo.
There are several ways of loading a song.
var song = {
title: 'Factum Par Fictio',
artist: 'Revolution Void',
album: 'Increase the Dosage',
cover: 'http://api.jamendo.com/get2/image/album/redirect/?id=15656&imagesize=150',
urls: [
'http://api.jamendo.com/get2/stream/track/redirect/?id=15656&streamencoding=mp31',
'http://api.jamendo.com/get2/stream/track/redirect/?id=15656&streamencoding=ogg2'
],
host: 'jamendo'
};
crescendo.load(song);
This method requires that you know the song's UID.
var songUID = 15656; // can be a string or an integer
var host = 'jamendo';
crescendo.load(songUID, host);
Search for a song on a web-service a web-service, providing a query string.
This method returns an array containing javascript object that can immediatly be passed to the play()
method.
Here again, several ways of doing so.
crescendo natively supports Jamendo, SoundCloud, TinySong & Grooveshark.
// Jamendo
var results = crescendo.search('jamendo', 'revolution void factum par fictio');
// TinySong
var results = crescendo.search('tinysong', 'archive dangervisit');
/**
* SoundCloud and Grooveshark require an API token ;)
*/
// SoundCloud
var token = 'aefcd765fecda877876dfac786faf';
var results = crescendo.search('soundcloud', 'muse darkshines', token);
// Grooveshark
var token = '765543876gfcaddacfgafc8767';
var results = crescendo.search('grooveshark', 'ratm born of a broken man', token);
The search()
method also allows you to query a custom service.
The service must send a JSON encoded single array or single object.
No special processing will be executed on this response and the search()
method will only return the decoded array/object.
var endPoint = 'http://my-music-service.you/search';
var results = crescendo.search(endPoint, 'sting englishman in new york');
Play a song previously loaded.
Pause the currently playing song.
Stop the currently playing/paused song.
Toggle song looping.
Change the volume level.
Reset the player with the options passed to $('#my-player').crescendo();
.
onCreate
onLoad
onLoadFinished
onPlay
onPause
onStop
onVolumeUpdate
onReset