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="/?url=https%3A//api.soundcloud/tracks/136405212&color=ff5500&auto_play=false&hide_related=false&show_artwork=true&show_ments=true&show_user=true&show_reposts=false"></iframe>
I want to try and play SoundCloud assets without this embed; instead, I want to find out how to:
- use an HTML5 audio player to play the song
- play a song without any audio players (i.e. "play this song
onLoad
")
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 )
Examples:
- Attempt on JSFiddle: /
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./player/?url=https%3A//api.soundcloud./tracks/136405212&color=ff5500&auto_play=false&hide_related=false&show_artwork=true&show_ments=true&show_user=true&show_reposts=false"></iframe>
I want to try and play SoundCloud assets without this embed; instead, I want to find out how to:
- use an HTML5 audio player to play the song
- play a song without any audio players (i.e. "play this song
onLoad
")
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./docs/api/guide#playing)
Examples:
- Attempt on JSFiddle: http://jsfiddle/mnbishop017/PbhCC/
2 Answers
Reset to default 9Expanding on @Marco's answer:
var xhr = new XMLHttpRequest(),
stream = new Audio(),
client_id = '?client_id=d4ab52d80ed2e7790c3a243495b30093';
xhr.open('GET', 'http://api.soundcloud./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();
You can try SoundCloud's JavaScript API for streaming tracks and other stuff.