I am trying to upload a song to soundcloud using the souncloud API and javascript. But I don't seem to be able to do it. This is my javascript
function ADDTRACK() {
var test = document.getElementById('SongTrack').files[0];
SC.get("http://api.soundcloud.com/users/redstr/tracks.json?client_id=3200814596a029b47877e63edfe6066c", {
limit: 1
}, function(tracks) {
SC.POST({
tracks: {
description: 'This track was recorded in Berlin',
asset_data: '@' + test
}
});
});
}
And this is my HTML upload
<input type="file" id ="SongTrack" name="pic" accept="audio/*" />
<button type="button" onclick="ADDTRACK()" />Add TRACK</button>
I get no errors, so can anyone point me in what im doing wrong?
From: http://developers.soundcloud.com/docs/api/guide#uploading
// the JavaScript SDK does not by itself have access
// to the filesystem, so instead this example records
// some audio in the browser and uploads it.
SC.connect(function() {
SC.record({
start: function() {
window.setTimeout(function() {
SC.recordStop();
SC.recordUpload({
track: { title: 'This is my sound' }
});
}, 5000);
}
}
});
So you can't directly upload the track with javascript.
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