1.0.24 • Published 6 years ago

react-native-play-sound v1.0.24

Weekly downloads
18
License
ISC
Repository
github
Last release
6 years ago

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>
        
1.0.24

6 years ago

1.0.23

6 years ago

1.0.22

6 years ago

1.0.21

6 years ago

1.0.20

6 years ago

1.0.19

6 years ago

1.0.18

6 years ago

1.0.17

6 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago