Controlling Soundcloud HTML5 Widget Player with custom buttons

后端 未结 1 1236
时光取名叫无心
时光取名叫无心 2020-12-25 09:26

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

相关标签:
1条回答
  • 2020-12-25 09:55

    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>
    
    0 讨论(0)
提交回复
热议问题