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):
根据SoundCloud API指南,我可以在web页面或web应用程序上播放来自SoundCloud的声音,而无需使用嵌入式播放器(下面的示例代码):
<iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/136405212&color=ff5500&auto_play=false&hide_related=false&show_artwork=true&show_comments=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:
我想尝试在没有嵌入的情况下播放SoundCloud资产;相反,我想知道如何:
- use an HTML5 audio player to play the song
- 使用HTML5音频播放器播放歌曲。
- play a song without any audio players (i.e. "play this song
onLoad
") - 播放一首没有任何音频播放器的歌曲。“玩这首歌onLoad”)
Any help with this, including anything that can use JavaScript and/or jQuery, will be much appreciated.
任何对此的帮助,包括任何可以使用JavaScript和/或jQuery的东西,都将非常感谢。
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)
是的,你也可以播放应用程序的声音。根据您的需要,您可以嵌入播放器小部件,使用JavaScript SDK在浏览器中流音频内容,或者将流url提供给您自己的音频播放器。您还可以使用我们的小部件API来控制播放器和处理事件。播放(http://developers.soundcloud.com/docs/api/guide)
Examples:
- Attempt on JSFiddle: http://jsfiddle.net/mnbishop017/PbhCC/
- 尝试在JSFiddle:http://jsfiddle.net/mnbishop017/PbhCC/
2 个解决方案
#1
2
You can try SoundCloud's JavaScript API for streaming tracks and other stuff.
你可以尝试一下SoundCloud的JavaScript API来流音乐和其他东西。
#2
8
Expanding on @Marco's answer:
扩大@Marco的回答:
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();
#1
2
You can try SoundCloud's JavaScript API for streaming tracks and other stuff.
你可以尝试一下SoundCloud的JavaScript API来流音乐和其他东西。
#2
8
Expanding on @Marco's answer:
扩大@Marco的回答:
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();