SoundCloud API - how to play private sound with HTML5 <audio> tag

I would like to play sound with HTML5 tag.

The source code is shown below:

  SC.get("/tracks/153068147", {}, function(sound, error) {
    $('#player').attr('src', sound.stream_url + '?client_id=' + client_id);
  });

When I set the sound to public, it works well. But when I set it as private, it does not work. What is the problem?

By the way, I also authenticated my APP with SC.connect before playing it. And the sound also loads with my SoundCloud account.

0
source share
1 answer

you need to replace http with https and add user_auth_token to the url like this:

`$('#player').attr('src', sound.stream_url.replace('http:','https:') + '?client_id=' + client_id+'&oauth_token=' + oAuthToken);`
0
source

All Articles