Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/daniel-hayes/react-native-simple-audio
A simple react native audio module
https://github.com/daniel-hayes/react-native-simple-audio
android audio audio-player react react-hooks react-native react-native-module swift5 typescript
Last synced: 4 days ago
JSON representation
A simple react native audio module
- Host: GitHub
- URL: https://github.com/daniel-hayes/react-native-simple-audio
- Owner: daniel-hayes
- License: apache-2.0
- Created: 2019-11-05T03:40:09.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T00:45:45.000Z (almost 2 years ago)
- Last Synced: 2024-11-30T19:15:43.159Z (22 days ago)
- Topics: android, audio, audio-player, react, react-hooks, react-native, react-native-module, swift5, typescript
- Language: TypeScript
- Homepage:
- Size: 1.95 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-native-simple-audio
[![codecov](https://codecov.io/gh/daniel-hayes/react-native-simple-audio/branch/master/graph/badge.svg)](https://codecov.io/gh/daniel-hayes/react-native-simple-audio)
[![npm version](https://badge.fury.io/js/react-native-simple-audio.svg)](https://badge.fury.io/js/react-native-simple-audio)## Install
`yarn add react-native-simple-audio`### iOS
`cd ios && pod install && cd .. # CocoaPods on iOS needs this extra step`#### Run
`react-native run-ios`or build manually:
1. `xed -b ios`
2. Run project in Xcode#### NOTE ABOUT iOS USAGE
Currently, there are two other changes that need to take place before the app will properly build.
1. This package has a minimum requirement of iOS 10.0. So if you are building an application for anything lower than 10.0, you need to go into `/ios/Podfile` and change the first line to `platform :ios, '10.0'`.
2. There's a strange build issue that seems to sometimes occur with Swift based custom modules: https://stackoverflow.com/questions/52536380/why-linker-link-static-libraries-with-errors-ios/54586937#54586937 Following these steps fixes the issue. I will work on either automating this or hopefully a future version of RN will eliminate the need.### Android
COMING SOON
## Example usage
```javascript
import {
ActivityIndicator,
Button,
View,
Text
} from 'react-native';import { useAudioPlayer } from 'react-native-simple-audio';
export const Player = ({ url }) => {
const [player, error] = useAudioPlayer(url);if (error) {
// handle error
console.log(error);
}return (
{player.status.loading && !player.status.ready ? (
) : (
<>
player.seekBackwards(20)}
/>
player.seekForwards(20)}
/>
{player.status.currentTime.formatted} -
{player.status.duration.formatted}
>
)}
)
};// Player component usage with remote url
```
## TODO
- Add full example
- Add Android functionality