score:1

Accepted answer

i've investigated almost any react native solution for playing audio and various approaches of using javascript settimeout()/setinterval(), but none of them were satisfactory in terms of time stability and accuracy.

probably the only way to go at the moment is to glue some native module like this: https://developer.apple.com/library/content/samplecode/hellometronome/introduction/intro.html to js side, as described in rn docs: https://facebook.github.io/react-native/docs/native-modules-ios.html, which gives a pretty decent result, but unfortunately, it's ios only, of course.

score:7

the delay that you configure for settimeout and setinterval should never be thought of as an exact delay time. they represent the "minimum" amount of time that you'll wait before the function is executed. this is because the user-agent places the callback into the event queue when the time has elapsed, but if the user-agent is still working on some other task, the callback will sit there.

you should also know that there is a built-in absolute minimum time that you are never going to be able to go under of roughly 9-14ms. this is due to the internals of the user-agent.


Related Query

More Query from same tag