Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Controlling Soundcloud HTML5 Widget Player with custom buttons

I wanted to do something similar to what I saw on SoundClouds HTML5 Widget API PLayground page where they have external buttons that control the player : http://w.soundcloud.com/player/api_playground.html

Eventually I'll be hiding the player widget itself and using those buttons as the music controller.

Any suggestions or tips would be awesome, I posted it here: http://jsfiddle.net/alexsethalex/qcKed/1/

like image 487
user578968 Avatar asked Jan 20 '26 21:01

user578968


1 Answers

Have you checked out the Widget API documentation?

Here's a super simple example:

<!doctype html>
<html>
<head>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  <script src="http://w.soundcloud.com/player/api.js"></script>
  <script>
   $(document).ready(function() {
     var widget = SC.Widget(document.getElementById('soundcloud_widget'));
     widget.bind(SC.Widget.Events.READY, function() {
       console.log('Ready...');
     });
     $('button').click(function() {
       widget.toggle();
     });
   });
  </script>
</head>
<body>
  <iframe id="soundcloud_widget"
      src="http://w.soundcloud.com/player/?url=https://api.soundcloud.com/tracks/39804767&show_artwork=false&liking=false&sharing=false&auto_play=true"
      width="420"
      height="120"
      frameborder="no"></iframe>
  <button>Play / Pause</button>
</body>
</html>
like image 93
Paul Osman Avatar answered Jan 22 '26 10:01

Paul Osman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!