react-native-audio-concat 0.2.0 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AudioConcat.podspec +10 -0
- package/README.md +57 -8
- package/android/build.gradle +2 -1
- package/package.json +1 -1
package/AudioConcat.podspec
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require "json"
|
|
2
2
|
|
|
3
3
|
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1'
|
|
4
5
|
|
|
5
6
|
Pod::Spec.new do |s|
|
|
6
7
|
s.name = "AudioConcat"
|
|
@@ -20,6 +21,15 @@ Pod::Spec.new do |s|
|
|
|
20
21
|
"cpp/**/*.{hpp,cpp}",
|
|
21
22
|
]
|
|
22
23
|
|
|
24
|
+
s.pod_target_xcconfig = {
|
|
25
|
+
"HEADER_SEARCH_PATHS" => [
|
|
26
|
+
"${PODS_ROOT}/RCT-Folly",
|
|
27
|
+
],
|
|
28
|
+
"GCC_PREPROCESSOR_DEFINITIONS" => "$(inherited) FOLLY_NO_CONFIG FOLLY_CFG_NO_COROUTINES",
|
|
29
|
+
"OTHER_CPLUSPLUSFLAGS" => folly_compiler_flags,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
23
33
|
s.dependency 'React-jsi'
|
|
24
34
|
s.dependency 'React-callinvoker'
|
|
25
35
|
|
package/README.md
CHANGED
|
@@ -1,27 +1,76 @@
|
|
|
1
1
|
# react-native-audio-concat
|
|
2
2
|
|
|
3
|
-
audio
|
|
3
|
+
Concatenate audio files and silence periods into a single audio file for React Native.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- ✅ Concat multiple audio files with silence periods
|
|
8
|
+
- ✅ Support for iOS and Android
|
|
9
|
+
- ✅ High performance using [Nitro Modules](https://nitro.margelo.com/)
|
|
10
|
+
- ✅ Output in M4A format
|
|
6
11
|
|
|
12
|
+
## Installation
|
|
7
13
|
|
|
8
14
|
```sh
|
|
9
15
|
npm install react-native-audio-concat react-native-nitro-modules
|
|
16
|
+
```
|
|
10
17
|
|
|
11
|
-
> `react-native-nitro-modules` is required as this library relies on [Nitro Modules](https://nitro.margelo.com/).
|
|
18
|
+
> **Note:** `react-native-nitro-modules` is required as this library relies on [Nitro Modules](https://nitro.margelo.com/).
|
|
19
|
+
|
|
20
|
+
### iOS
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
cd ios && pod install
|
|
12
24
|
```
|
|
13
25
|
|
|
26
|
+
### Android
|
|
27
|
+
|
|
28
|
+
No additional steps required.
|
|
14
29
|
|
|
15
30
|
## Usage
|
|
16
31
|
|
|
32
|
+
```typescript
|
|
33
|
+
import { concatAudioFiles } from 'react-native-audio-concat';
|
|
34
|
+
|
|
35
|
+
// Concatenate audio files with silence periods
|
|
36
|
+
const data = [
|
|
37
|
+
{ filePath: '/path/to/audio1.m4a' },
|
|
38
|
+
{ durationMs: 500 }, // 500ms silence
|
|
39
|
+
{ filePath: '/path/to/audio2.m4a' },
|
|
40
|
+
{ durationMs: 1000 }, // 1 second silence
|
|
41
|
+
{ filePath: '/path/to/audio3.m4a' }
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
const outputPath = '/path/to/merged.m4a';
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
const result = await concatAudioFiles(data, outputPath);
|
|
48
|
+
console.log('Concatenated audio file:', result);
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.error('Failed to concatenate audio:', error);
|
|
51
|
+
}
|
|
52
|
+
```
|
|
17
53
|
|
|
18
|
-
|
|
19
|
-
import { multiply } from 'react-native-audio-concat';
|
|
54
|
+
## API
|
|
20
55
|
|
|
21
|
-
|
|
56
|
+
### `concatAudioFiles(data, outputPath)`
|
|
22
57
|
|
|
23
|
-
|
|
24
|
-
|
|
58
|
+
Concatenates audio files and silence periods into a single output file.
|
|
59
|
+
|
|
60
|
+
**Parameters:**
|
|
61
|
+
|
|
62
|
+
- `data`: `AudioDataOrSilence[]` - Array of audio files and silence periods to merge. Each item can be either:
|
|
63
|
+
- `{ filePath: string }` - Path to an audio file
|
|
64
|
+
- `{ durationMs: number }` - Duration of silence in milliseconds
|
|
65
|
+
- `outputPath`: `string` - Absolute path where the merged audio file will be saved (M4A format)
|
|
66
|
+
|
|
67
|
+
**Returns:**
|
|
68
|
+
|
|
69
|
+
- `Promise<string>` - Resolves with the output file path
|
|
70
|
+
|
|
71
|
+
## Example
|
|
72
|
+
|
|
73
|
+
Check out the [example app](example/) for a complete working example.
|
|
25
74
|
|
|
26
75
|
|
|
27
76
|
## Contributing
|
package/android/build.gradle
CHANGED
|
@@ -24,7 +24,8 @@ apply plugin: "com.android.library"
|
|
|
24
24
|
apply plugin: "kotlin-android"
|
|
25
25
|
apply from: '../nitrogen/generated/android/audioconcat+autolinking.gradle'
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
// Note: Don't apply "com.facebook.react" plugin in library modules
|
|
28
|
+
// as it triggers autolinking. Only the app module should autolink dependencies.
|
|
28
29
|
|
|
29
30
|
def getExtOrIntegerDefault(name) {
|
|
30
31
|
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["AudioConcat_" + name]).toInteger()
|