Created
June 1, 2014 19:07
-
-
Save pkarman/5f4cb8388bbf40a9def8 to your computer and use it in GitHub Desktop.
apm audio api html5 example
This file contains hidden or 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
| <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