Cross-platform metronome module for iOS and Android
npm install react-native-metronome-module
You must include a metronome.wav file in the following locations for this module to work:
- android/app/src/main/res/raw
- ios (and add the file to the project in XCode)
import MetronomeModule from "react-native-metronome-module";
// ...
MetronomeModule.setBPM(100);
MetronomeModule.setShouldPauseOnLostFocus(true);
MetronomeModule.start();
// ...
if (await MetronomeModule.isPlaying()) {
const bpm = await MetronomeModule.getBPM();
console.log(`Metronome playing at ${bpm}bpm!`);
MetronomeModule.stop();
}
start: () => void
stop: () => void
setBPM: (newBPM: number) => void
getBPM: () => Promise<number>
setShouldPauseOnLostFocus: (shouldPause: boolean) => void
getShouldPauseOnLostFocus: () => Promise<number>
isPlaying: () => Promise<boolean>
isPaused: () => Promise<boolean>
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT