Soundcloud HTML5 Widget API に苦労しています。メソッドとイベントは正常に動作していますが、ゲッターをログに記録できません。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>