Reputation: 95
I'm trying to upload a track to SoundCloud via JAVASCRIPT API, with this code:
<!DOCTYPE html>
<html>
<head>
<title>Upload track</title>
<script src="https://connect.soundcloud.com/sdk/sdk-3.0.0.js"></script>
<script>
var blob = "MY_BLOB";
SC.initialize({
client_id: 'MY_CLIENT_ID',
oauth_token: 'MY_TOKEN',
refresh_token: 'MY_REFRESH_TOKEN'
});
var upload = SC.upload({
file: blob, // a Blob of your WAV, MP3...
title: 'HTML test',
genre: 'Electronic',
description: 'This is a good! track'
});
</script>
</head>
<body>
</body>
</html>
I get the oauth_token and refresh_token from a previous request. The response I get is:
{"errors":[{"error_message":"500 - Internal Server Error"}]}
I thought that my blob was incorrect, but if I put it in an audio tag:
<audio controls>
<source src="MY_BLOB" type="audio/ogg">
</audio>
and it works. That is to say the blob not is the problem. What is the problem?
Upvotes: 3
Views: 202
Reputation: 1379
You should try as per
<script src="https://connect.soundcloud.com/sdk/sdk-3.0.0.js"></script>
<script>
// When you have recorded a song with the SDK or any Web Audio application,
// you can upload it if it's in a format that is accepted
SC.upload({
file: theBlob, // a Blob of your WAV, MP3...
title: 'This is my sound'
});
</script>
Source = https://developers.soundcloud.com/docs/api/guide#uploading
Upvotes: 1