Search code examples
javascriptrubyapisoundcloudsoundmanager2

SoundCloud Stream URL 404


I'm trying to stream a track from soundcloud using their Javascript SDK, but I keep getting a 404 when asking for the stream url.

I tried multiple ways including:

$(document).ready(function() {
  SC.initialize({
    client_id: "CLIENT_ID",
  });
  playTrack();
});

var playTrack = function() {

  SC.stream("/i1/tracks/137078163", function(sound) {
    sound.play();
  });
}

which returns a 404.

client = Soundcloud.new(:client_id => 'YOUR_CLIENT_ID')
track = client.get('/tracks/293')
stream_url = client.get(track.stream_url, :allow_redirects => true)

also returns a 404.

The only way I got it to work was using a different stream url on SO, but I'd like to know why using their JS SDK doesn't work.


Solution

  • In your JS example, whats that for an endpoint /i1/tracks/137078163 ?

    When i use the track-id from your ruby example, in your JS slightly changed, its working.

    So i'd say your track-id is wrong in your js ex.

    Pls. check.

    $(document).ready(function() {
    
    SC.initialize({client_id: "679877a8ddb9badc6a2a75373c5f3de7",});
    
    var playTrack = function() 
    { SC.stream("/tracks/293", function(sound) { sound.play();});}   
    
    playTrack();
    });
    

    Working fiddle here: http://jsfiddle.net/iambnz/Y5Y25/