Reputation: 23
I'm working with this thing: http://grouprecorder.soundcloudlabs.com – a recording Widget from Soundcloud. I got it to work as it's supposed to, recording and uploading tracks to a specified group, as well as listing that group's tracks. On top of that, however, I wanted to add a simple function, making an experimental audio commentary system on a blog.
In order to do that I must differentiate between comments made on different posts. I managed to do so, passing a WordPress post's ID to the widget's iFrame, and carry that on as a SoundCloud track tag. It uploads precisely as it should to.
Then, however, once I want to filter the tracks to be listed in the widget, to only show ones with the correct tag, I'm a little lost.
This is the original bit of code:
return SC.get(GR.groupUrl + "/tracks", {
limit: 5,
},
Simple enough. I have tried adding all variations of tags, taglist, tag_list, that seem remotely possible, as in:
return SC.get(GR.groupUrl + "/tracks", {
limit: 5,
tags: postIDtag
},
– postIDtag being my otherwise very well functioning postID variable.
And yet the widget keeps posting the whole list of the group's tracks, unfiltered.
Others seem to have had related problems in the past. It seems to be impossible to filter by user and tags at the same time. Perhaps the same goes for groups. If so using the tags alone would be fine by me, as I can make them specific enough to exclude any tracks outside the group. But I'm a novice at javascript, so I'm unsure if it's me or them, that's at fault here. Can anyone help me out, or am I trying something not supported in the API?
Upvotes: 1
Views: 948
Reputation: 4167
I've done a lot of work with the Soundcloud API in the past and found that the API itself for rendering specific data on a page is pretty ... awful.
What I do to avoid these issues is work with the tracks array itself rather than working with the array via the soundcloud API. Here's an example:
$.getJSON("http://api.soundcloud.com/groups/57713/tracks.json?client_id=YOUR_CLIENT_ID", function(data) {
var tracks = $.map(data, function(track) {
return {
track: track.title,
stream: track.stream_url + '?client_id=YOUR_CLIENT_ID',
tags: track.tag_list
};
});
console.log(tracks);
});
Updated: 27.05.2014
What you'll now see in your console are two separate logs:
console.log(data)
shows the returned objects from soundcloudconsole.log(this.tracks)
shows the objects from soundcloud in their manipulated form.Upvotes: 1