使用自定义按钮控制Soundcloud HTML5 Widget Player

问题描述 投票:2回答:1

我想做一些类似于我在SoundClouds HTML5 Widget API PLayground页面上看到的内容,它们有外部按钮来控制播放器:http://w.soundcloud.com/player/api_playground.html

最终我将隐藏播放器小部件本身并使用这些按钮作为音乐控制器。

任何建议或提示都很棒,我在这里发布:http://jsfiddle.net/alexsethalex/qcKed/1/

javascript custom-controls soundcloud
1个回答
14
投票

你检查过Widget API documentation了吗?

这是一个非常简单的例子:

<!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>
© www.soinside.com 2019 - 2024. All rights reserved.