017Bluefield
017Bluefield

Reputation: 161

SoundCloud API: how to use SoundCloud song w/o the embed player?

According to the SoundCloud API Guide, I can play sounds from SoundCloud on a web page or web application, without using the embedded player (example code below):

<iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/136405212&amp;color=ff5500&amp;auto_play=false&amp;hide_related=false&amp;show_artwork=true&amp;show_comments=true&amp;show_user=true&amp;show_reposts=false"></iframe>

I want to try and play SoundCloud assets without this embed; instead, I want to find out how to:

Any help with this, including anything that can use JavaScript and/or jQuery, will be much appreciated.

Original text:

Yep, you can also play sounds from your application. Depending on your needs, you can embed a player widget, use the JavaScript SDK to stream audio content in the browser, or feed a stream url into your own audio player. You can also use our Widget API to control the player and handle events. (from http://developers.soundcloud.com/docs/api/guide#playing)

Examples:

Upvotes: 1

Views: 3933

Answers (2)

idbehold
idbehold

Reputation: 17168

Expanding on @Marco's answer:

var xhr = new XMLHttpRequest(),
    stream = new Audio(),
    client_id = '?client_id=d4ab52d80ed2e7790c3a243495b30093';
xhr.open('GET', 'http://api.soundcloud.com/tracks/136405212.json' + client_id);
xhr.onload = function(){
  var track = JSON.parse(xhr.responseText);
  stream.src = track.stream_url + client_id;
  stream.play();
};
xhr.send();

Upvotes: 9

Marco
Marco

Reputation: 634

You can try SoundCloud's JavaScript API for streaming tracks and other stuff.

Upvotes: 2

Related Questions