react-native-volume

0.0.1 • Public • Published

react-native-volume

A react-native bridge for controlling media volume on Android.

Instalation

android/settings.gradle

include ':react-native-volume'
project(':react-native-volume').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-volume/android')

android/app/build.gradle

dependencies {
   ...
   compile project(':react-native-volume')
}

MainActivity.java

On top, where imports are:

import com.tapme.RNVolume.VolumePackage;

Under .addPackage(new MainReactPackage()):

.addPackage(new VolumePackage())

Note: In react-native >= 0.29.0 you have to edit MainApplication.java

MainApplication.java (react-native >= 0.29.0)

On top, where imports are:

import com.tapme.RNVolume.VolumePackage;

Under .addPackage(new MainReactPackage()):

.addPackage(new VolumePackage())

Usage

import { getVolume, setVolume, getMaxVolume, onVolumeChange } from 'react-native-volume';
 
// Get the maximum value for the media stream
const maxVolume = getMaxVolume();
console.log(maxVolume);
 
// Get the current volume level as integer, returns a promise
getVolume().then(volume => console.log(volume));
 
// Set the current volume, (doesn't show system popup)
setVolume(10);
 
// Listen to volume changes
onVolumeChange(volume => console.log(volume));

Readme

Keywords

none

Package Sidebar

Install

npm i react-native-volume

Weekly Downloads

4

Version

0.0.1

License

MIT

Last publish

Collaborators

  • juliano92