简体   繁体   中英

Web audio API - get current time of a source inside an AudioContext

I would like to reproduce a simple sampler on my browser.

I've 4 different sources inside my same AudioContext() . I managed to play/pause each source independently.

I'd like to get the current time of a source when I play it. Unfortunately from what I read, I can only get the currentTime value of my context.

Is there a way to get the current time of a buffer source? Should I create 4 contexts with one source inside instead?

Thank you very much

EDIT: here's a preview, the sounds doesn't seems to play since it is on an https host. I'd like to get the current time of my source each time I click on play.

https://codepen.io/michaelgrc/pen/YzpMRZw

If by "current time" of a source when it's playing, you mean to figure out where in the buffer source the output is currently playing, then the answer is that there's no way to do that.

However, see the WebAudio V2 issue #26 that might help with what you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM