Created
May 27, 2016 20:30
-
-
Save amonks/6af96cf239b17c15f3194ca1dc0a7010 to your computer and use it in GitHub Desktop.
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
var context = new webkitAudioContext(), | |
audio = new Audio(), | |
source, | |
// `stream_url` you'd get from | |
// requesting http://api.soundcloud.com/tracks/6981096.json | |
url = 'https://api.soundcloud.com/tracks/6981096/stream' + | |
'?client_id=SOMETHING_SECRET'; | |
audio.crossOrigin = "anonymous"; // via http://stackoverflow.com/questions/31308679/mediaelementaudiosource-outputs-zeros-due-to-cors-access-restrictions-local-mp3 | |
audio.src = url; | |
source = context.createMediaElementSource(audio); | |
source.connect(context.destination); | |
source.mediaElement.play(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment