Code Monkey home page Code Monkey logo

react-native-system-sounds's Introduction

@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 ..

Mostly automatic install with react-native link (RN < 0.60)

  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 [email protected]: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

react-native-system-sounds's People

Contributors

asadwan avatar r4dic4l avatar victorien-t avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

r4dic4l

react-native-system-sounds's Issues

Error: null is not an object

Following the example in the documentation, I get this

null is not an object (evaluating 'RNSystemSoundsNativeModule.playSystemSound')

while trying to use with Expo

Incompatible with Gradle Version 9

I believe this package needs to be updated to work with grade v9.

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/user.name/Documents/GitHub/ProjectName/node_modules/@dashdoc/react-native-system-sounds/android/build.gradle' line: 130

* What went wrong:
A problem occurred configuring project ':dashdoc_react-native-system-sounds'.
> Could not set unknown property 'classifier' for task ':dashdoc_react-native-system-sounds:androidSourcesJar' of type org.gradle.api.tasks.bundling.Jar.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 13s
error Failed to install the app. Command failed with exit code 1: ./gradlew tasks FAILURE: Build failed with an exception. * Where:
Build file '/Users/user.name/Documents/GitHub/ProjectName/node_modules/@dashdoc/react-native-system-sounds/android/build.gradle' line: 130 * What went wrong:
A problem occurred configuring project ':dashdoc_react-native-system-sounds'.
> Could not set unknown property 'classifier' for task ':dashdoc_react-native-system-sounds:androidSourcesJar' of type org.gradle.api.tasks.bundling.Jar. * Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 13s
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :gradle-plugin:pluginDescriptors
> Task :gradle-plugin:processResources
> Task :gradle-plugin:compileKotlin
> Task :gradle-plugin:compileJava NO-SOURCE
> Task :gradle-plugin:classes
> Task :gradle-plugin:jar
> Task :gradle-plugin:inspectClassesForKotlinIC > Configure project :app
Warning: The 'kotlin-android-extensions' Gradle plugin is deprecated. Please use this migration guide (https://goo.gle/kotlin-android-extensions-deprecation) to start working with View Binding (https://developer.android.com/topic/libraries/view-binding) and the 'kotlin-parcelize' plugin.
5 actionable tasks: 5 executed

bug : build failed in RN 0.70

in RN 0.70 :

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file 'C:\myproject\node_modules\@dashdoc\react-native-system-sounds\android\build.gradle' line: 23

* What went wrong:
A problem occurred evaluating project ':dashdoc_react-native-system-sounds'.
> Plugin with id 'maven' not found.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':dashdoc_react-native-system-sounds'.
> compileSdkVersion is not specified. Please add it to build.gradle

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.