I'm trying to play a music from Soundcloud API inside an audio tag, my main goal is develop a spectrum analyzer with d3.js and some other stuff, but I just can't make it works. My current code is (here's a fiddle):
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Spectrum Analyzer</title>
</head>
<body>
<h1>Spectrum Analyzer</h1>
<audio id="player" controls></audio>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//connect.soundcloud.com/sdk.js"></script>
<script src="./stuff.js"></script>
</body>
</html>
In stuff.js I have this:
(function($) {
'use strict';
var client_id = "SOME CLIENT ID";
SC.initialize({
client_id: client_id
});
SC.get("/tracks/55424024", {}, function(sound, error) {
$('#player').attr('src', sound.stream_url + '?client_id=' + client_id);
});
})(jQuery);
The player shows up (in FF, when there's an error, it disappears), but I can't start the music. I'm aware of the current state of audio tag, e.g. it does not plays mp3 in FF. I'll use some library to fix it later.
So, what am I doing wrong? Is there a better way to solve this?