1

下面的代码是从 CoffeeScript 编译的,希望它仍然可读

(function() {

  $(function() {
    var PLAYLIST_ID, SOUNDCLOUD_ID, tracks, tracks_ready, tracks_total;
    SOUNDCLOUD_ID = '6d5064768cc29c71e1f66691f435589a';
    PLAYLIST_ID = '1768866';
    SC.initialize({
      client_id: SOUNDCLOUD_ID
    });
    tracks = [];
    tracks_total = 0;
    tracks_ready = function() {
      return tracks[0].play();
    };
    return SC.get('/playlists/' + PLAYLIST_ID, function(pl) {
      var track;
      track = pl.tracks[0];
      return SC.stream('/tracks/' + track.id, function(sound) {
        tracks.push(sound);
        return tracks_ready();
      });
    });
  });

}).call(this);

代码在 jquery 和 "//connect.soundcloud.com/sdk.js" 包含后执行。

它给出了 Uncaught TypeError: Cannot set property 'id' of undefined 并带有以下跟踪:

window.SC.SC.Helper.merge.stream - window.SC.SC.Helper.merge.whenStreamingReady - some SM2 stuff
4

1 回答 1

2

哦,SC.stream 中似乎有一个错误。快速解决方法是传递可选选项对象: SC.stream('/tracks/' + track.id, {}, function(sound)....) 将确保尽快修复。

于 2012-04-30T14:15:19.553 回答