-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:SolankiYogesh/react-native-audio-focus
- Loading branch information
Showing
1 changed file
with
69 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,83 @@ | ||
# react-native-audio-focus | ||
## AudioFocus | ||
|
||
The react-native-audio-focus package is a module for React Native that allows your app to handle audio focus events, such as incoming calls or other apps playing audio. It provides a way to respond to these events by firing events within your React Native application, enabling you to manage your app's audio playback and UI appropriately. | ||
This package provides functionality to handle audio focus changes and incoming calls in a React Native application on Android. | ||
|
||
## Installation | ||
### Installation | ||
|
||
```sh | ||
npm install react-native-audio-focus | ||
``` | ||
To install this package, follow these steps: | ||
|
||
1. Install the package using npm or Yarn: | ||
|
||
```bash | ||
npm install react-native-audio-focus | ||
``` | ||
|
||
or | ||
|
||
```bash | ||
yarn add react-native-audio-focus | ||
``` | ||
|
||
2. Link the native module: | ||
|
||
```bash | ||
react-native link react-native-audio-focus | ||
``` | ||
|
||
### Usage | ||
|
||
To use the `AudioFocus` module in your React Native code, follow these steps: | ||
|
||
1. Import the module: | ||
|
||
## Usage | ||
```javascript | ||
import AudioFocus from 'react-native-audio-focus'; | ||
``` | ||
|
||
```js | ||
import { multiply } from 'react-native-audio-focus'; | ||
2. Add listeners to handle audio focus changes and incoming calls: | ||
|
||
// ... | ||
```javascript | ||
// Add listener for audio focus changes | ||
AudioFocus.addListener('onAudioFocusChange', (focusChange) => { | ||
// Handle audio focus change event | ||
}); | ||
|
||
const result = await multiply(3, 7); | ||
// Add listener for incoming calls | ||
AudioFocus.addListener('onIncomingCall', () => { | ||
// Handle incoming call event | ||
}); | ||
``` | ||
|
||
3. Remove listeners when they are no longer needed: | ||
|
||
```javascript | ||
AudioFocus.removeListener(); | ||
``` | ||
|
||
### Permissions | ||
|
||
Make sure to add the necessary permissions to your `AndroidManifest.xml` file to handle incoming calls: | ||
|
||
```xml | ||
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> | ||
``` | ||
|
||
## Contributing | ||
### Troubleshooting | ||
|
||
If you encounter any issues or errors while using this package, please refer to the [GitHub repository](https://github.com/SolankiYogesh/react-native-audio-focus) for further information and troubleshooting steps. | ||
|
||
### License | ||
|
||
This package is released under the [MIT License](https://opensource.org/licenses/MIT). | ||
|
||
### Contributing | ||
|
||
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow. | ||
Contributions to this package are welcome! If you find any bugs or want to suggest new features, please open an issue or submit a pull request on the [GitHub repository]((https://github.com/SolankiYogesh/react-native-audio-focus/issues)). | ||
|
||
## License | ||
### Acknowledgments | ||
|
||
MIT | ||
This package is inspired by the [React Native Audio Focus]((https://github.com/SolankiYogesh/react-native-audio-focus)) package. | ||
|
||
--- | ||
### Contact | ||
|
||
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob) | ||
For any inquiries or questions, please contact [[email protected]](mailto:solankiyogesh3500@gmail.com). |