#Tunez
A simple, lightweight jQuery plugin used to display songs recently scrobbled by a Last.fm user.
A Last.fm API key is required for this plugin. Click here to aquire one.
##Instructions
Include jQuery and the plugin in the head or footer of your page.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="/js/plugins/tunez.js"></script>
Create an element with a class or ID that will display the recently scrobbled songs.
<div id="tunez"></div>
Initialize the plugin targeting the class, ID or element.
$('#tunez').tunez();
The plugin will replace the element with an ordered or unordered list with each scrobbled track and each detail will be wrapped in a span for you to style it however you wish.
####Example Ouput:
<ol>
<li>
<img src="http://last.fm" alt="ALbum Title" class="artwork">
<span class="details">
<span class="title"><a href="http://last.fm" target="_blank">Song Title</a></span>
<span class="album">(Album Title)</span>
<span class="artist"><a href="http://last.fm" target="_blank">Artist</a></span>
</span>
</li>
</ol>
####Options
-
key: "api key"
A string that defines your Last.fm API key (default: null). - username: "username"
A string that defines the user's Last.fm username (default: null). - limit: integer
An integer that indicates the amount of scrobbled songs to display (default: 5). - ordered: boolean
A boolean value that indicates whether or not the list of songs should be ordered (default: true). - href: true / false
A boolean that indicates whether or not the song and artist should be links (default: true). - album: true / false
A boolean that indicates whether or not you want the album name shown (default: true). - artwork: boolean
A boolean to indicate whether or not the album artwork is displayed (default: true). - success: function
A callback function that runs after the data has been retrieved (default: function()). - error: function
A callback function that runs if there was an error retrieving the data (default: function()).
#####Example:
$(function() {
$('#tunez').tunez({
key: '1e2fbabb102c1fa0760379b9ef6f9ecc',
username: 'michaelynch',
limit: 10,
ordered: false,
href: false,
album: false,
artwork: false,
success: function() {
console.log('Rock and roll.')
},
error: function() {
console.log('Without music, this is a mistake.');
}
});
});