如何更改 Web Audio API 中音频缓冲源的时间?
How do I change the time of an audio buffer source in the Web Audio API?
如果我有音频元素,我可以使用类似
audioElement.currentTime=5;
但是如何在网络音频中设置音频缓冲源的时间API?有没有类似的:
var source=context.createBufferSource();
source.currentTime=5;
澄清一下,我想在音频缓冲区的音频中播放 5 秒。
如果你想让 AudioBufferSourceNode
从时间 5 开始播放,你可以使用 src.start(5)
或者 src.start(5 + context.currentTime)
。这假设与 AudioBufferSourceNode
关联的 AudioBuffer
至少有 5 秒的音频要播放。否则你什么也听不到。
src.start()
采用第二个参数进行偏移:https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/start
src.start(when,offset,duration)
如果我使用 src.start(0,5)
,我将在 5 秒后启动音频缓冲区!
如果我有音频元素,我可以使用类似
audioElement.currentTime=5;
但是如何在网络音频中设置音频缓冲源的时间API?有没有类似的:
var source=context.createBufferSource();
source.currentTime=5;
澄清一下,我想在音频缓冲区的音频中播放 5 秒。
如果你想让 AudioBufferSourceNode
从时间 5 开始播放,你可以使用 src.start(5)
或者 src.start(5 + context.currentTime)
。这假设与 AudioBufferSourceNode
关联的 AudioBuffer
至少有 5 秒的音频要播放。否则你什么也听不到。
src.start()
采用第二个参数进行偏移:https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/start
src.start(when,offset,duration)
如果我使用 src.start(0,5)
,我将在 5 秒后启动音频缓冲区!