Soundcloud: Cannot set property 'id' of undefined when trying to play the song

非 Y 不嫁゛ 提交于 2019-12-08 04:53:13

问题


The code below is compiled from CoffeeScript, hope it's still readable

(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);

The code is executed after jquery and "//connect.soundcloud.com/sdk.js" are included.

And it gives Uncaught TypeError: Cannot set property 'id' of undefined with the following trace:

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

回答1:


Oh, there seems to be a bug in SC.stream. Quick workaround is to pass the optional options object: SC.stream('/tracks/' + track.id, {}, function(sound)....) Will make sure to get a fix out there as soon as possible.



来源:https://stackoverflow.com/questions/10385015/soundcloud-cannot-set-property-id-of-undefined-when-trying-to-play-the-song

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!