# react-native-play-sound

> Play music and sounds with react-native

Latest version **1.0.24** (published 2018-02-02) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-native-play-sound
pnpm add react-native-play-sound
yarn add react-native-play-sound
bun add react-native-play-sound
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.24 |
| Published | 2018-02-02 |
| First published | 2017-12-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 23 |
| Maintainers | ghitatomy |
| Keywords | sound |

## Links

- npm: https://www.npmjs.com/package/react-native-play-sound
- Repository: https://github.com/luminos-software/react-native-play-sound
- Homepage: https://github.com/luminos-software/react-native-play-sound#readme
- Issues: https://github.com/luminos-software/react-native-play-sound/issues
- npm.io page: https://npm.io/package/react-native-play-sound

## Recent versions

- 1.0.24 (latest) — 2018-02-02
- 1.0.23 — 2018-02-02
- 1.0.22 — 2018-01-29
- 1.0.21 — 2018-01-24
- 1.0.20 — 2018-01-22
- 1.0.19 — 2018-01-22
- 1.0.18 — 2018-01-22
- 1.0.17 — 2018-01-22
- 1.0.16 — 2018-01-22
- 1.0.15 — 2018-01-16
- 1.0.14 — 2018-01-16
- 1.0.13 — 2018-01-16
- 1.0.12 — 2018-01-16
- 1.0.11 — 2018-01-12
- 1.0.10 — 2018-01-12
- … 10 more at https://npm.io/package/react-native-play-sound/versions

## README

## react-native-play-sound
React Native module for playing sound and melody on iOS, Android

## Installation via npm
First install the npm package from your app directory:
```
    npm install react-native-play-sound --save
```
## Installation via yarn
First save package name in package.json:
```
    yarn add react-native-play-sound
```
After install package saved:
```
    yarn
```
## Then link it automatically using:
```
    react-native link react-native-play-sound
```

## Methods
```
PlaySound('sound_name')
PlaySoundRepeat('sound_name')
StopSound()
PlaySoundMusicVolume('volume')

```

## Basic usage
ANDROID: Save your sound clip files under the directory android/app/src/main/res/raw. Note that files in this directory must be lowercase and underscored (e.g. my_file_name.mp3) and that subdirectories are not supported by Android.

IOS: Open Xcode and add your sound files to the project.

In React-native project:

```
import { PlaySound, StopSound, PlaySoundRepeat, PlaySoundMusicVolume } from 'react-native-play-sound';

// And on press or anywhere you need it :
// PlaySound('sound_name')

// Note that sound name must be identical on Android and iOS

// Example:
        <TouchableOpacity
          onPress={() => PlaySound('jingle_bells_keyboard')}
          style={styles.touchable}
        >
          <Text>Play Jingle Bell</Text>
        </TouchableOpacity>
        
        <TouchableOpacity
          onPress={() => PlaySoundRepeat('jingle_bells_keyboard')}
          style={styles.touchable}
        >
          <Text>Play Repeated Jingle Bell</Text>
        </TouchableOpacity>
        
        <TouchableOpacity
            onPress={() => StopSound()}
            style={styles.touchable}
        >
            <Text>Stop Jingle Bell</Text>
        </TouchableOpacity>
        
        <TouchableOpacity
            onPress={() => PlaySoundMusicVolume(0.4)}
            style={styles.touchable}
        >
            <Text>Set sound volume at 0.4</Text>
        </TouchableOpacity>
        
```

---
_Source: https://npm.io/package/react-native-play-sound · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
