Created
February 22, 2014 05:49
-
-
Save nulltask/9149287 to your computer and use it in GitHub Desktop.
WASABEAT API Tutorial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<style> | |
body { | |
font-family: 'Helvetica Neue'; | |
margin: 50px; | |
} | |
</style> | |
<!-- Documentation: http://developers.wasabeat.com --> | |
<!-- $ php -S localhost:8080 --> | |
<!-- Diagram: https://cacoo.com/diagrams/jfC4OLtFxERrVVdj --> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.js"></script> | |
<script> | |
$(function() { | |
$.getJSON("http://api.wasabeat.com/v1/tracks/search?bpm=100..125&tonality=12a&genre_id=900,901,902&count=5&page=1") | |
.done(function(data) { | |
data.tracks.forEach(function(track) { | |
console.log(track); | |
var $track = $('<div>' + | |
'<p>Title: ' + track.title + ' (' + track.mix_title + ')</p>' + | |
'</div>').appendTo('body'); | |
var audio = new Audio(); | |
audio.controls = true; | |
audio.src = track.urls.sample; | |
$(audio).appendTo($track); | |
var image = new Image(); | |
image.src = track.images.larger; | |
$(image).appendTo($track); | |
}); | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<h1>WASABEAT API Tutorial</h1> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment