Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uploading song to Soundcloud account using javascript

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?

like image 712
Clonebaby Avatar asked Oct 23 '22 04:10

Clonebaby


1 Answers

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.

like image 188
SuperKingTurban Avatar answered Nov 05 '22 08:11

SuperKingTurban