Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
react-native-volume-manager
Advanced tools
React Native module which adds the ability to change the system volume on iOS and Android, listen to volume changes and supress the native volume UI to build your own volume slider or UX.
Adds the ability to change the system volume on iOS and Android, listen to volume changes and supress the native volume UI to build your own volume slider or UX.
npm install react-native-volume-manager
or
yarn add react-native-volume-manager
import VolumeManager from 'react-native-volume-manager';
// ...
// set volume
VolumeManager.setVolume(0.5); // float value between 0 and 1
// set volume with extra options
VolumeManager.setVolume(0.5, {
type: 'system', // defaults to "music" (Android only)
showUI: true, // defaults to false, can surpress the native UI Volume Toast (iOS & Android)
playSound: false, // defaults to false (when pushing hardware buttons) (Android only)
});
// get volume async, type defaults to "music" (Android only)
// iOS has only one type of Volume (system)
const { volume } = await VolumeManager.getVolume(type: 'music');
// or the oldschool way
VolumeManager.getVolume.then((result) => {
console.log(result.volume); // returns the current volume as a float (0-1)
});
// listen to volume changes
useEffect(() => {
const volumeListener = VolumeManager.addListener((result) => {
console.log(result.volume); // returns the current volume as a float (0-1)
});
// clean up function
return function () {
// remove listener
volumeListener.remove();
}
})
Method | Description |
---|---|
Volume | |
getVolume(type:string) => Promise | Get the system volume. type must be one of music , call , system , ring , alarm , notification , default is music . (Android only, iOS will always report the system volume) |
setVolume(value:float, config:object) | Set the system volume by specified value, from 0 to 1. 0 for mute, and 1 for the max volume.config can be {type: 'music', playSound:true, showUI:true} type : must be one of music , call , system , ring , alarm , notification , default is music . (Android only) playSound : Whether to play a sound when changing the volume, default is false (Android only)showUI : Show the native system volume UI, default is false (Android & iOS) |
addListener(callback) | Listen to volume changes (soft- and hardware. addListener will return the listener which is needed for cleanup. Result passed to callback contains volume as key. |
listener.remove() | Remove the listener when you don't need it anymore. Store the return of const listener = VolumeManager.addListener() in a variable and call it with .remove() . See the example above. |
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
Based on https://github.com/c19354837/react-native-system-setting, rewritten to TS and optimized for current React Native versions.
FAQs
React Native module which adds the ability to change the system volume on iOS and Android, listen to volume changes and supress the native volume UI to build your own volume slider or UX.
The npm package react-native-volume-manager receives a total of 13,817 weekly downloads. As such, react-native-volume-manager popularity was classified as popular.
We found that react-native-volume-manager demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.