Skip to content

Instantly share code, notes, and snippets.

@pkarman
Created June 1, 2014 19:07
Show Gist options
  • Select an option

  • Save pkarman/5f4cb8388bbf40a9def8 to your computer and use it in GitHub Desktop.

Select an option

Save pkarman/5f4cb8388bbf40a9def8 to your computer and use it in GitHub Desktop.
apm audio api html5 example
<html lang="en">
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(document).ready(function() {
var audioId = 'apm-audio:/marketplace/segments/2013/07/19/marketplace_segment11_20130719';
$.ajax({
url: 'http://api.publicradio.org/audio/v2/?id='+audioId+'&ref=bar',
//dataType: 'jsonp',
})
.done(function(resp) {
console.log('done');
console.log(resp);
var mp3 = resp[audioId].podcast.http_file_path;
$('#audio-player').html('<audio controls><source src="'+mp3+'" type="audio/mpeg"></audio>');
$('#audio-meta').html(resp[audioId].podcast.title);
})
.fail(function(xhr) {
console.log('xhr failed');
console.log(xhr.getAllResponseHeaders());
console.log(xhr.getResponseHeader('X-APM'));
})
.always(function(xhr) {
//console.log('xhr always ftw');
})
;
});
</script>
</head>
<body>
<div id="audio-meta"></div>
<div id="audio-player"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment