SoundCloud - getDuration(没有按钮的回调函数)

时间:2014-02-16 22:31:29

标签: javascript soundcloud

好的,所以我整天都在研究回调功能,但我仍然处于亏损状态。我正在尝试加载页面并在SoundCloud上显示歌曲的持续时间。我已经看过很多关于如何使用按钮进行操作的示例,但我试图采用自动化方法。有什么想法吗?

<!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>

</head>
<body>
    <center>
        <iframe id="playing" width="500" height="400" scrolling="no" frameborder="yes" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/66816173&amp;auto_play=false&amp;hide_related=false&amp;visual=true"></iframe> 
    </center>

  <script>
       $(document).ready(function() {
            var widget = SC.Widget(document.getElementById('playing'));

            widget.bind(SC.Widget.Events.READY, function() {
                console.log('Ready...');
            });

            widget.getDuration(function(duration) {alert(duration)});

        });


  </script>
</body>
</html>

0 个答案:

没有答案