A jQuery plugin for showing the currently playing track on Last.fm
The plugin requires jQuery, we recommend using the latest version. You also need to have a Last.fm API key.
- Add Required Scripts
Make sure you include jQuery before adding the plugin at the bottom of your HTML document
<script src="/scripts/vendor/jquery.js"></script>
<script src="/scripts/plugins/lastfmnowplaying.js"></script>
- Add a Template
Add a template into your HTML document as in the example below. This can appear anywhere on your web page and can contain any markup you'd like. The template makes use of a number of custom tags surrounded by {}'s. Each template must have it's own ID.
<script type="text/template" id="lastFmWidget">
<div>{ track.artist }</div>
<div>{ track.title }</div>
<div>{ track.album }</div>
<img src="{ track.image.medium }">
</script>
- Call Widget
The widget is called using the following in your main JavaScript file.
$('#lastFmWidget').lastfmNowPlaying({
apiKey: 'YOUR-API-KEY',
members: ['YOUR-LASTFM-USERNAME']
});
Be sure to update the apiKey and members options with your own information.