UNPKG

@dashdoc/react-native-system-sounds

Version:

A module to play system sounds and beeps for React Native on iOS and Android (no sound files).

29 lines 990 B
import { Platform } from "react-native"; import RNSystemSoundsNativeModule from "./RNSystemSoundsModule"; import { AndroidSoundIDs, iOSSoundIDs } from "./constants"; class RNSystemSounds { static AndroidSoundIDs = AndroidSoundIDs; static iOSSoundIDs = iOSSoundIDs; static Beeps = { Positive: Platform.select({ ios: iOSSoundIDs.Headset_AnswerCall, android: AndroidSoundIDs.TONE_PROP_BEEP, }), Negative: Platform.select({ ios: iOSSoundIDs.Headset_EndCall, android: AndroidSoundIDs.TONE_PROP_ACK, }), }; static play(soundID) { if (Platform.OS === "android") { RNSystemSoundsNativeModule.stopSystemSound(); } RNSystemSoundsNativeModule.playSystemSound(soundID); } static beep(soundID = this.Beeps.Positive) { this.play(soundID); } } export default RNSystemSounds; export { AndroidSoundIDs, iOSSoundIDs }; //# sourceMappingURL=index.js.map