Skip to content

Instantly share code, notes, and snippets.

@dave-4k
Created May 26, 2017 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dave-4k/9839d682e7f7ad92f96c06f8e53f96d3 to your computer and use it in GitHub Desktop.
Save dave-4k/9839d682e7f7ad92f96c06f8e53f96d3 to your computer and use it in GitHub Desktop.
Play Next With SoundCloud HTML5 API
/**
* Play Next With SoundCloud HTML5 API
*/
body { padding: 20px 20px 0; background-color: #eaeaea;}iframe { display: block; width: 728px; margin: 0 auto 20px; box-shadow: 0 0 6px -1px #ddd; background: #fff; border: 2px solid #fff; border-radius: 5px;}
<iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/132387987&amp;auto_play=false"></iframe>
<iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/268605105&amp;auto_play=false"></iframe>
var $players = $('iframe[src*="soundcloud"]') , i = 0 ;$players.wrap('<div class="my-soundcloud"></div>');$players.each(function () { $(this).attr('data-local-soundcloud-player-id', i); i = i + 1;});if ( $players.length > 0 ) { $.getScript('//w.soundcloud.com/player/api.js', function (data, status) { if ( status === 'success' ) { $players.each(function (index) { var sc = SC.Widget(this); sc.bind(SC.Widget.Events.READY, function() { sc.bind(SC.Widget.Events.FINISH, function () { if(index < $players.length - 1){ SC.Widget($players[index + 1]).play(); } }); }); }); } });}
{"view":"separate","fontsize":"100","seethrough":"","codespector_bootstrap":"","codespector_jquery":"","page":"all"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment