JSPM

@dashdoc/react-native-system-sounds

1.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1198
  • Score
    100M100P100Q130448F
  • License MIT

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

Package Exports

  • @dashdoc/react-native-system-sounds
  • @dashdoc/react-native-system-sounds/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@dashdoc/react-native-system-sounds) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@dashdoc/react-native-system-sounds

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

Heavily inspired by react-native-a-beep
Built with react-native-module-init

Installation

Mostly automatic install with autolinking (RN > 0.60)

  1. Install package from npm
yarn add @dashdoc/react-native-system-sounds
  1. Install iOS Pods
cd ios && pod install && cd ..
  1. Install package from npm
yarn add @dashdoc/react-native-system-sounds
  1. Link package with react-native link
yarn react-native link @dashdoc/react-native-system-sounds
  1. Install iOS Pods
cd ios && pod install && cd ..

Usage

import RNSystemSounds from '@dashdoc/react-native-system-sounds';

// ...

<Button
  title="Play positive beep"
  onPress={() => RNSystemSounds.beep()}
/>

<Button
  title="Play negative beep"
  onPress={() => RNSystemSounds.beep(RNSystemSounds.Beeps.Negative)}
/>

<Button
  title="Play custom system sound"
  onPress={() =>
    RNSystemSounds.play(
      Platform.select({
        android: RNSystemSounds.AndroidSoundIDs.TONE_CDMA_ABBR_ALERT,
        ios: RNSystemSounds.iOSSoundIDs.AudioToneBusy,
      })
    )
  }
/>

Example

  1. Clone the repository, enter the example directory and install dependencies.
git clone git@github.com:dashdoc/react-native-system-sounds.git
cd example/
yarn install
  1. Install iOS Pods,
cd ios && pod install && cd ..
  1. Start bundler.
yarn start
  1. On a new terminal, run the app on the <platform> of your choice (ios or android).
cd example/
yarn <platform>

Caveats

This does not work on iOS simulator.

License

MIT