Javascript SoundCloud-getDuration(不带按钮的回调函数)

Javascript SoundCloud-getDuration(不带按钮的回调函数),javascript,soundcloud,Javascript,Soundcloud,好吧,我整天都在研究回调函数,但我还是不知所措。我正在尝试在SoundCloud上加载页面并显示歌曲的持续时间。我已经看到了很多关于如何使用按钮的例子,但我正在尝试一种自动化的方法。有什么想法吗 <!doctype html> <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

好吧,我整天都在研究回调函数,但我还是不知所措。我正在尝试在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>

$(文档).ready(函数(){
var widget=SC.widget(document.getElementById('playing');
bind(SC.widget.Events.READY,function()){
log('Ready…');
});
getDuration(函数(持续时间){alert(持续时间)});
});

尝试将getDuration调用移动到READY callbackNICE中!太好了,谢谢你!