Is it possible to detect if a track does not exist using the soundcloud widget?
I tried using the
SC.Widget.Events.ERROR
event to no avail.
Here is a JSFiddle
I stumbled upon exact the same problem,
SC.Widget.Events.ERROR
doesn't fire if a track on soundcloud is deleted.
My workaround looks like this:
var link = "https://soundcloud.com/jaytantrumdesire/tantrum-desire-get-with-it";
var isDef = SC.get('/resolve', { url: link }, function(track) {
return track.id;
});
if (isDef != undefined) {
// function to run when track exists
} else if (isDef == undefined) {
// function to run when track deleted/not available
}
Since i work with direct links I check if the direct link has an ID, if it has, the track is available, if doesnt't, the track is not available.
If you are working with the track IDs I guess you could check if the ID has a track title:
var trackid = "32260824";
var isDef = SC.get('/tracks/' + trackid, function(track) {
return track.title;
});
To call these functions you must create an app on soundcloud to get a ClientID to use the soundcloud JavaScript SDK. An introduction on how to use it can be found on Soundcloud Developers
First post here, hope this can help someone!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With