Play mp3 file after uploading it with html5 drag and drop upload

后端 未结 2 824
隐瞒了意图╮
隐瞒了意图╮ 2020-12-13 11:32

Is it possible to first upload an mp3 file with the html5 drag and drop upload system, and then play it with webkit\'s audio API (http://chromium.googlecode.com/svn/trunk/sa

2条回答
  •  失恋的感觉
    2020-12-13 12:08

    When I run the jsfiddle example the sound is distorted this is due that both the processor and source are connected to context.destination. To get it to work I removed the line source.connect(context.destination); and in the processAudio function I added code to copy the input samples to the output

    var inL = e.inputBuffer.getChannelData(0);
    var inR = e.inputBuffer.getChannelData(1);
    var outL= e.outputBuffer.getChannelData(0);
    var outR =e.outputBuffer.getChannelData(1);
    
    var n = inL.length;
    for (var i = 0; i < n; i++) {
        outL[i] = inL[i];
        outR[i] = inR[i];
    }
    

提交回复
热议问题