Soundcloud:尝试播放歌曲时无法设置未定义的属性"id" [英] Soundcloud: Cannot set property 'id' of undefined when trying to play the song

查看:361
本文介绍了Soundcloud:尝试播放歌曲时无法设置未定义的属性"id"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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

它给出了Uncaught TypeError:无法通过以下跟踪设置未定义的属性'id':

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

推荐答案

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

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.

这篇关于Soundcloud:尝试播放歌曲时无法设置未定义的属性"id"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆