我有一个Array(实时音频流5分钟剪辑)列表,我想将其组合为一个文件,并按阵列顺序在播放器中播放。
function init() {
// Fix up prefixing
window.AudioContext = window.AudioContext || window.webkitAudioContext;
context = new AudioContext();
bufferLoader = new BufferLoader(
context,
[
audio stream 1,
audio stream 2,
audio stream 3
],
finishedLoading
);
bufferLoader.load();
}
这是合并多个流的最佳方法。
function play() {
//end of stream has been reached
if (audiobuffer.length === 0) { return; }
let source = context.createBufferSource();
//get the latest buffer that should play next
source.buffer = audiobuffer.shift();
source.connect(context.destination);
//add this function as a callback to play next buffer
//when current buffer has reached its end
source.onended = play;
source.start();
}
答案 0 :(得分:0)