最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - SoundCloud API: how to use SoundCloud song wo the embed player? - Stack Overflow

programmeradmin0浏览0评论

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&amp;color=ff5500&amp;auto_play=false&amp;hide_related=false&amp;show_artwork=true&amp;show_ments=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:

  • 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&amp;color=ff5500&amp;auto_play=false&amp;hide_related=false&amp;show_artwork=true&amp;show_ments=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:

  • 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/
Share Improve this question edited Jun 26, 2014 at 19:28 017Bluefield asked Jun 23, 2014 at 22:34 017Bluefield017Bluefield 1612 silver badges13 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 9

Expanding 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.

发布评论

评论列表(0)

  1. 暂无评论