lak*_*nen 11 javascript html5 google-chrome web-audio-api
如何使用Web音频API反向播放音频?我似乎无法在API文档中找到任何内容......
Kev*_*nis 15
你可以这样做:
var context = new AudioContext(),
request = new XMLHttpRequest();
request.open('GET', 'path/to/audio.mp3', true);
request.responseType = 'arraybuffer';
request.addEventListener('load', function(){
context.decodeAudioData(request.response, function(buffer){
var source = context.createBufferSource();
Array.prototype.reverse.call( buffer.getChannelData(0) );
Array.prototype.reverse.call( buffer.getChannelData(1) );
source.buffer = buffer;
});
});
Run Code Online (Sandbox Code Playgroud)
这是一个非常简单的例子 - 但基本上你可以Float32Array
为AudioBuffer中的每个通道获取实例并反转它们.
如果你有一个AudioBufferSourceNode元素:
audioBufferSourceNode.playbackRate = -1;
Run Code Online (Sandbox Code Playgroud)
-编辑-
Webkit没有该功能.
资料来源:https://bugs.webkit.org/show_bug.cgi?id = 69725
归档时间: |
|
查看次数: |
5216 次 |
最近记录: |