【问题标题】:Can't get Getters from SoundCloud HTML5 Widget API无法从 SoundCloud HTML5 Widget API 获取 Getter
【发布时间】:2013-01-22 19:37:57
【问题描述】:

我正在为 Soundcloud HTML5 Widget API 苦苦挣扎。方法和事件工作正常,但我无法记录 getter。我一直在查看 Soundcloud API 文档,但找不到问题所在。 Soundcloud Playground 运行良好,但他们在博客 http://developers.soundcloud.com/blog/html5-widget-api 中提供的示例并没有。所以我想知道,我在这里遗漏了什么,还是 API 有问题?这是我剥离的 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" type="text/javascript"></script>
<script>
        $(document).ready(function() {
            var widget = SC.Widget(document.getElementById('sc-widget'));
            widget.bind(SC.Widget.Events.READY, ready());

            function ready() {
                widget.getDuration(function(durationSC) {
                    console.log('Duration: ' + durationSC);
                });
            }

            $('button').click(function() {
                widget.toggle();
            });
        });
    </script>
</head>
<body>
    <iframe id="sc-widget" src="http://w.soundcloud.com/player/?url=https://api.soundcloud.com/tracks/39804767&show_artwork=false&liking=false&sharing=false&auto_play=false" height="195" scrolling="no" width="480" frameborder="no"></iframe>
<button>Play / Pause</button>
</body>
</html>

【问题讨论】:

  • 您正在调用 ready() 而不是将其作为回调传递 – widget.bind(SC.Widget.Events.READY, ready);

标签: html widget soundcloud


【解决方案1】:

感谢您报告此事。现在 API 确实存在问题 - 快速解决方法是在小部件的 iframe src 中使用 https

我们将尝试尽快部署修复程序并将文档修复为指向应该使用的https

【讨论】:

    猜你喜欢
    • 2013-04-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多