Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
<!DOCTYPE html>
<title>Echo Nest + Spotify Play Button Demo</title>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<link type="text/css" href="demo_styles.css" rel="stylesheet" />
<h1 id='title'> Echo Nest + Spotify Play Button Demo</h1>
<div class ='info'>
A demo of how the
<a href="">Echo Nest playlist API</a>
can work with the new Spotify Widget. See <a
href="">MusicMachinery</a> for more
This version uses multiple single-track players. Also see the <a href="SpotifyTrackList.html">single multi-track
player version</a>.
<span class='box'> Seed artist:
<input title="Artist" type="text" size=24 id="artist"
onkeydown="if (event.keyCode == 13) newArtist()" name="artist" value='weezer'/>
<button value="go" id="go" name="go" disabled onclick="newArtist()"> Go </button>
<div id="info"> </div>
<div id="all_results">
<div id='tracks'>
<h2> The Playlist</h2>
<div id="results"> </div>
<script type="text/javascript">
jQuery.ajaxSettings.traditional = true;
var embed = '<iframe src="" style="width:300px; height:380px;" frameborder="0" allowTransparency="true">';
function fetchArtistPlaylist(artist, wandering, variety) {
var url = '';
info("Creating the playlist ...");
$.getJSON(url, { 'artist': artist, 'format':'jsonp',
'bucket': [ 'id:spotify-WW', 'tracks'], 'limit' : true,
'results': 12, 'type':'artist-radio', 'variety' : variety,
'distribution' : wandering ? 'wandering' : 'focused' }, function(data) {
for (var i = 0; i < data.response.songs.length; i++) {
var song = data.response.songs[i];
var tid = song.tracks[0].foreign_id.replace('-WW', '');
var tembed = embed.replace('TRACK_URI', tid);
var li = $("<span>").html(tembed);
function newArtist() {
var artist = $("#artist").val();
fetchArtistPlaylist(artist, false, .2);
function info(txt) {
$(document).ready(function() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment