![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
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 7,539 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.