Soundcloud Api , Please Help



Just to make it easier i have this working script on jsfiddle :

Right now it works but its the same track id everytime you open that page.

**I need some help to make this script generate a new track id on page refresh **
Is this possible and how please?


This post was flagged by the community and is temporarily hidden.


The solution is quite easy.

We have to:

  1. Get all the tracks (we have to delete limit)
  2. Pick random track

    client_id: "9d7b8f85e4719525a2ca97e8814e14fe",
    redirect_uri: "",

var userId = 165459296; //this is the user id to loop tracks

SC.get("/tracks", {
    user_id: userId,
}, function(tracks) {
    var randomTrack = tracks[Math.floor(Math.random() * tracks.length)];


Thank you so much this worked.


You're very welcome :slight_smile: