使用javascript将歌曲上传到Soundcloud帐户

前端之家收集整理的这篇文章主要介绍了使用javascript将歌曲上传到Soundcloud帐户前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试使用souncloud API和 javascript将一首歌上传到soundcloud.但我似乎无法做到这一点.这是我的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
            }
        });
    });
}

这是我的HTML上传

<input type="file" id ="SongTrack" name="pic" accept="audio/*" />
      <button type="button"   onclick="ADDTRACK()" />Add TRACK</button>

我没有错误,所以任何人都可以指出我做错了什么?

解决方法

来自: 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);
            }
          }    
    });

所以你不能用javascript直接上传曲目.

猜你在找的JavaScript相关文章