samedi 7 février 2015

stream soundcloud track with JavaScript dosen't work

Would you guys help me in this? : i want to make a list from my soundcloud tracks and play any track when i click it with JavaScript, but it dosen't wrok with me :(


html file



<script src="//connect.soundcloud.com/sdk.js"></script> <body>
<ol id="track-list"></ol> </body>


js file:



function PlayIt(ID){
SC.stream("/tracks"+ID, function(sound){
soundManager.stopAll();
sound.play();
});

}



SC.initialize({
client_id: "YOUR_CLIENT_ID",
redirect_uri: "http://ift.tt/1v0LYB0",
});

/**
Once that's done you are all set and ready to call the SoundCloud API.
**/



/**
Call to the SoundCloud API.
Retrieves list of tracks, and displays a list with links to the tracks showing 'tracktitle' and 'track duration'
**/

var userId = 39090345; // user_id of Prutsonic

SC.get("/tracks", {
user_id: userId,
limit: 100
}, function (tracks) {

var tmp = '';

for (var i = 0; i < tracks.length; i++) {
var TrackId=tracks[i].id;
tmp = '<a href="#" onclick="PlayIt('+TrackId +')">' + tracks[i].title + ' - ' + tracks[i].duration + '</a>';

$("<li/>").html(tmp).appendTo("#track-list");
}

});


You can also check it here: http://ift.tt/1IqHDwI


*this is not my code, but i try to make it better


Aucun commentaire:

Enregistrer un commentaire