如何为特定轨道调用soundcloud sdk

时间:2016-08-22 01:12:22

标签: javascript soundcloud

评论代码失败。未注释的代码有效。 soundcloud对象SC的正确代码是什么才能获得一个特定的轨道?

    /*
    SC.stream( '/tracks/259637476', function( sm_object ){
  var track = {
            id: 259637476,
            title: 'Time is your most valuable and scarcest resource',
            artist: 'Ceiteach',
    url: sm_object.url
  };

  $rootScope.$apply(function () {
      $rootScope.songs.push(track);
  });
    }) ;
    */

  SC.get("/groups/55517/tracks", {
    limit: 5
  }, function(tracks) {
    for (var i = 0; i < tracks.length; i ++) {
        SC.stream( '/tracks/' + tracks[i].id, function( sm_object ){
            var track = {
                id: tracks[i].id,
                title: tracks[i].title,
                artist: tracks[i].genre,
                url: sm_object.url
            };

            $rootScope.$apply(function () {
                $rootScope.songs.push(track);
            });
        });
    }         
});

1 个答案:

答案 0 :(得分:0)

注释掉的代码实际上有效。我发现我有错误的曲目ID :-(( - :

SC.stream('/tracks/270887767', function(sm_object) {

    var track = {
        id: 270887767,
        title: 'Time is your most valuable and scarcest resource',
        artist: 'Ceiteach',
        url: sm_object.url
    };


    $rootScope.songs.push(track);


});