webaudio, audiocontext 跳转到位置

webaudio, audiocontext jump to position

在我的代码中,我将 AudioContext.currentTime 设置为跳转到播放曲目的不同位置。这是行不通的。这是旧代码,所以我不确定网络音频规范是否已更改或者我只是创建了错误的代码。多年来,我一直在寻找一种解决方案来解决这个问题。我看到的唯一解决方案似乎涉及停止旧声音并创建新的缓冲源。

有没有办法在播放曲目中指定位置?

编辑:我知道 AudioContext.currentTime 现在被指定为只读

我是这样做的:

  function playAudio(buffer, offsetInSeconds, duration) {
    console.log('start playing audio');
    var audioTrack = context.createBufferSource();
    audioTrack.connect(context.destination);
    audioTrack.buffer = buffer;     
    audioTrack.start(context.currentTime, offsetInSeconds,  duration);        
  }

是的,您每次都必须创建新的 bufferSource。