Skip to content

Commit

Permalink
docs: update README (#613)
Browse files Browse the repository at this point in the history
* docs: update README

added react-native-file-access instructions

* docs: update README

added react-native-file-access instructions

---------

Co-authored-by: Efstathios Ntonas <[email protected]>
  • Loading branch information
efstathiosntonas and Efstathios Ntonas authored Jun 11, 2024
1 parent 4ac5f89 commit f97f923
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,16 @@ onStopPlay = async () => {

If you want to get actual uri from the record or play file to actually grab it and upload it to your bucket, just grab the resolved message when using `startPlay` or `startRecord` method like below.

To access the file with more reliability, please use [react-native-blob-util](https://www.npmjs.com/package/react-native-blob-util). For example, below.
To access the file with more reliability, please use [react-native-blob-util](https://www.npmjs.com/package/react-native-blob-util) or [react-native-file-access](https://github.com/alpha0010/react-native-file-access). See below for examples.

```javascript
`react-native-blob-util`
```ts
import ReactNativeBlobUtil from 'react-native-blob-util'
...
const dirs = ReactNativeBlobUtil.fs.dirs;
const path = Platform.select({
ios: 'hello.m4a',
android: `${this.dirs.CacheDir}/hello.mp3`,
android: `${dirs.CacheDir}/hello.mp3`,
});
const uri = await audioRecorderPlayer.startRecord(path);
Expand All @@ -349,6 +352,8 @@ Also, above example helps you to setup manual path to record audio. Not giving p
To pass in specific URI in IOS, you need to append `file://` to the path. As an example using [RFNS](https://github.com/itinance/react-native-fs).

```javascript
import RNFetchBlob from 'rn-fetch-blob';
...
const dirs = RNFetchBlob.fs.dirs;
const path = Platform.select({
ios: `file://${RNFS.DocumentDirectoryPath}/hello.m4a`,
Expand All @@ -358,6 +363,20 @@ const path = Platform.select({
const uri = await audioRecorderPlayer.startRecord(path);
```
`react-native-file-access`
```ts
import { Dirs } from "react-native-file-access";
...
const path = Platform.select({
ios: 'hello.m4a',
android: `${Dirs.CacheDir}/hello.mp3`,
});

const uri = await audioRecorderPlayer.startRecord(path);
```
## Try yourself
1. Goto `Example` folder by running `cd Example`.
Expand Down

0 comments on commit f97f923

Please sign in to comment.