react-native-video-trim 4.0.0 → 5.0.0
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/LICENSE +1 -1
- package/README.md +124 -83
- package/VideoTrim.podspec +4 -4
- package/android/build.gradle +15 -54
- package/android/gradle.properties +2 -0
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/videotrim/VideoTrimModule.kt +660 -0
- package/android/src/main/java/com/videotrim/VideoTrimPackage.kt +33 -0
- package/android/src/main/java/com/{margelo/nitro/videotrim → videotrim}/enums/ErrorCode.java +1 -1
- package/android/src/main/java/com/{margelo/nitro/videotrim → videotrim}/interfaces/IVideoTrimmerView.java +1 -1
- package/android/src/main/java/com/{margelo/nitro/videotrim → videotrim}/interfaces/VideoTrimListener.java +5 -4
- package/android/src/main/java/com/{margelo/nitro/videotrim → videotrim}/utils/MediaMetadataUtil.java +1 -1
- package/android/src/main/java/com/{margelo/nitro/videotrim → videotrim}/utils/StorageUtil.java +1 -1
- package/android/src/main/java/com/{margelo/nitro/videotrim → videotrim}/utils/VideoTrimmerUtil.java +49 -39
- package/android/src/main/java/com/{margelo/nitro/videotrim → videotrim}/widgets/VideoTrimmerView.java +49 -46
- package/ios/AssetLoader.h +19 -0
- package/ios/AssetLoader.mm +87 -0
- package/ios/ErrorCode.h +9 -0
- package/ios/ProgressAlertController.h +15 -0
- package/ios/ProgressAlertController.mm +78 -0
- package/ios/VideoTrim.h +31 -0
- package/ios/VideoTrim.mm +663 -0
- package/ios/VideoTrimmer.h +67 -0
- package/ios/VideoTrimmer.mm +863 -0
- package/ios/VideoTrimmerThumb.h +23 -0
- package/ios/VideoTrimmerThumb.mm +175 -0
- package/ios/VideoTrimmerViewController.h +52 -0
- package/ios/VideoTrimmerViewController.mm +533 -0
- package/lib/module/NativeVideoTrim.js +5 -0
- package/lib/module/NativeVideoTrim.js.map +1 -0
- package/lib/module/index.js +59 -34
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NativeVideoTrim.d.ts +107 -0
- package/lib/typescript/src/NativeVideoTrim.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +21 -10
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +15 -18
- package/src/NativeVideoTrim.ts +113 -0
- package/src/index.tsx +68 -39
- package/android/CMakeLists.txt +0 -24
- package/android/src/main/cpp/cpp-adapter.cpp +0 -6
- package/android/src/main/java/com/margelo/nitro/videotrim/VideoTrim.kt +0 -629
- package/android/src/main/java/com/margelo/nitro/videotrim/VideoTrimPackage.kt +0 -22
- package/ios/AssetLoader.swift +0 -99
- package/ios/ErrorCode.swift +0 -17
- package/ios/ProgressAlertController.swift +0 -100
- package/ios/VideoTrim.swift +0 -60
- package/ios/VideoTrimImpl.swift +0 -860
- package/ios/VideoTrimmer.swift +0 -872
- package/ios/VideoTrimmerThumb.swift +0 -175
- package/ios/VideoTrimmerViewController.swift +0 -557
- package/lib/module/VideoTrim.nitro.js +0 -4
- package/lib/module/VideoTrim.nitro.js.map +0 -1
- package/lib/typescript/src/VideoTrim.nitro.d.ts +0 -240
- package/lib/typescript/src/VideoTrim.nitro.d.ts.map +0 -1
- package/nitrogen/generated/android/c++/JEditorConfig.hpp +0 -229
- package/nitrogen/generated/android/c++/JFileValidationResult.hpp +0 -61
- package/nitrogen/generated/android/c++/JFunc_void.hpp +0 -74
- package/nitrogen/generated/android/c++/JFunc_void_std__string_std__unordered_map_std__string__std__string_.hpp +0 -89
- package/nitrogen/generated/android/c++/JHybridVideoTrimSpec.cpp +0 -131
- package/nitrogen/generated/android/c++/JHybridVideoTrimSpec.hpp +0 -67
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/videotrim/EditorConfig.kt +0 -70
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/videotrim/FileValidationResult.kt +0 -28
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/videotrim/Func_void.kt +0 -80
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/videotrim/Func_void_std__string_std__unordered_map_std__string__std__string_.kt +0 -80
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/videotrim/HybridVideoTrimSpec.kt +0 -82
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/videotrim/videotrimOnLoad.kt +0 -35
- package/nitrogen/generated/android/videotrim+autolinking.cmake +0 -78
- package/nitrogen/generated/android/videotrim+autolinking.gradle +0 -27
- package/nitrogen/generated/android/videotrimOnLoad.cpp +0 -50
- package/nitrogen/generated/android/videotrimOnLoad.hpp +0 -25
- package/nitrogen/generated/ios/VideoTrim+autolinking.rb +0 -60
- package/nitrogen/generated/ios/VideoTrim-Swift-Cxx-Bridge.cpp +0 -88
- package/nitrogen/generated/ios/VideoTrim-Swift-Cxx-Bridge.hpp +0 -331
- package/nitrogen/generated/ios/VideoTrim-Swift-Cxx-Umbrella.hpp +0 -53
- package/nitrogen/generated/ios/VideoTrimAutolinking.mm +0 -33
- package/nitrogen/generated/ios/VideoTrimAutolinking.swift +0 -25
- package/nitrogen/generated/ios/c++/HybridVideoTrimSpecSwift.cpp +0 -11
- package/nitrogen/generated/ios/c++/HybridVideoTrimSpecSwift.hpp +0 -116
- package/nitrogen/generated/ios/swift/EditorConfig.swift +0 -519
- package/nitrogen/generated/ios/swift/FileValidationResult.swift +0 -57
- package/nitrogen/generated/ios/swift/Func_void.swift +0 -46
- package/nitrogen/generated/ios/swift/Func_void_FileValidationResult.swift +0 -46
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +0 -46
- package/nitrogen/generated/ios/swift/Func_void_double.swift +0 -46
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +0 -46
- package/nitrogen/generated/ios/swift/Func_void_std__string_std__unordered_map_std__string__std__string_.swift +0 -54
- package/nitrogen/generated/ios/swift/Func_void_std__vector_std__string_.swift +0 -46
- package/nitrogen/generated/ios/swift/HybridVideoTrimSpec.swift +0 -53
- package/nitrogen/generated/ios/swift/HybridVideoTrimSpec_cxx.swift +0 -222
- package/nitrogen/generated/shared/c++/EditorConfig.hpp +0 -245
- package/nitrogen/generated/shared/c++/FileValidationResult.hpp +0 -77
- package/nitrogen/generated/shared/c++/HybridVideoTrimSpec.cpp +0 -26
- package/nitrogen/generated/shared/c++/HybridVideoTrimSpec.hpp +0 -76
- package/src/VideoTrim.nitro.ts +0 -244
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2025
|
|
3
|
+
Copyright (c) 2025 Duc Trung Mai
|
|
4
4
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
5
|
of this software and associated documentation files (the "Software"), to deal
|
|
6
6
|
in the Software without restriction, including without limitation the rights
|
package/README.md
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
# Table of contents
|
|
1
2
|
- [Installation](#installation)
|
|
2
3
|
* [For iOS (React Native CLI project)](#for-ios-react-native-cli-project)
|
|
3
4
|
* [For Expo project](#for-expo-project)
|
|
4
5
|
* [Usage](#usage)
|
|
5
6
|
- [Methods](#methods)
|
|
6
|
-
* [showEditor(videoPath: string, config?: EditorConfig
|
|
7
|
+
* [showEditor(videoPath: string, config?: EditorConfig) => void)](#showeditorvideopath-string-config-editorconfig--void)
|
|
8
|
+
* [trim(url: string, options: TrimOptions): Promise<string>](#trimurl-string-options-trimoptions-promise)
|
|
7
9
|
* [isValidFile(videoPath: string)](#isvalidfilevideopath-string)
|
|
8
10
|
* [closeEditor()](#closeeditor)
|
|
9
11
|
* [listFiles()](#listfiles)
|
|
@@ -12,15 +14,14 @@
|
|
|
12
14
|
- [Callbacks (New arch)](#callbacks-new-arch)
|
|
13
15
|
* [showEditor](#showeditor)
|
|
14
16
|
* [closeEditor](#closeeditor-1)
|
|
15
|
-
- [Events (Old arch)](#events-old-arch)
|
|
16
17
|
- [Audio support](#audio-support)
|
|
17
18
|
- [Cancel trimming](#cancel-trimming)
|
|
18
19
|
- [Fail to load media](#fail-to-load-media)
|
|
20
|
+
- [Rotation](#rotation)
|
|
21
|
+
- [Use FFMPEG HTTPS version](#use-ffmpeg-https-version)
|
|
19
22
|
- [Android: update SDK version](#android-update-sdk-version)
|
|
20
23
|
- [Thanks](#thanks)
|
|
21
24
|
|
|
22
|
-
<!-- TOC end -->
|
|
23
|
-
|
|
24
25
|
# React Native Video Trim
|
|
25
26
|
<div align="center">
|
|
26
27
|
<h2>Video trimmer for your React Native app</h2>
|
|
@@ -31,7 +32,7 @@
|
|
|
31
32
|
|
|
32
33
|
## Features
|
|
33
34
|
- ✅ Support video and audio
|
|
34
|
-
- ✅ Support local files
|
|
35
|
+
- ✅ Support local files and remote files (remote files need `https` version, see below)
|
|
35
36
|
- ✅ Save to Photos, Documents and Share to other apps
|
|
36
37
|
- ✅ Check if file is valid video/audio
|
|
37
38
|
- ✅ File operations: list, clean up, delete specific file
|
|
@@ -46,7 +47,7 @@
|
|
|
46
47
|
|
|
47
48
|
```sh
|
|
48
49
|
# new arch
|
|
49
|
-
npm install react-native-video-trim
|
|
50
|
+
npm install react-native-video-trim
|
|
50
51
|
|
|
51
52
|
# old arch
|
|
52
53
|
npm install react-native-video-trim@^3.0.0
|
|
@@ -54,14 +55,12 @@ npm install react-native-video-trim@^3.0.0
|
|
|
54
55
|
# or with yarn
|
|
55
56
|
|
|
56
57
|
# new arch
|
|
57
|
-
yarn add react-native-video-trim
|
|
58
|
+
yarn add react-native-video-trim
|
|
58
59
|
|
|
59
60
|
# old arch
|
|
60
61
|
yarn add react-native-video-trim@^3.0.0
|
|
61
62
|
```
|
|
62
63
|
|
|
63
|
-
> `react-native-nitro-modules` is required in New Arch as this library relies on [Nitro Modules](https://nitro.margelo.com/).
|
|
64
|
-
|
|
65
64
|
## For iOS (React Native CLI project)
|
|
66
65
|
Run the following command to setup for iOS:
|
|
67
66
|
```
|
|
@@ -71,9 +70,10 @@ npx pod-install ios
|
|
|
71
70
|
You need to run `prebuild` in order for native code takes effect:
|
|
72
71
|
```
|
|
73
72
|
npx expo prebuild
|
|
74
|
-
|
|
75
|
-
npx pod-install ios
|
|
76
73
|
```
|
|
74
|
+
Then you need to restart to make the changes take effect
|
|
75
|
+
|
|
76
|
+
> Note that on iOS you'll need to run on real device, Expo Go may not work because of library linking
|
|
77
77
|
|
|
78
78
|
## Usage
|
|
79
79
|
|
|
@@ -92,7 +92,7 @@ showEditor(videoUrl, {
|
|
|
92
92
|
```
|
|
93
93
|
Usually this library will be used along with other library to select video file, Eg. [react-native-image-picker](https://github.com/react-native-image-picker/react-native-image-picker). Below is real world example:
|
|
94
94
|
|
|
95
|
-
```
|
|
95
|
+
```jsx
|
|
96
96
|
import * as React from 'react';
|
|
97
97
|
|
|
98
98
|
import {
|
|
@@ -102,11 +102,84 @@ import {
|
|
|
102
102
|
TouchableOpacity,
|
|
103
103
|
NativeEventEmitter,
|
|
104
104
|
NativeModules,
|
|
105
|
+
type EventSubscription,
|
|
105
106
|
} from 'react-native';
|
|
106
107
|
import { isValidFile, showEditor } from 'react-native-video-trim';
|
|
107
108
|
import { launchImageLibrary } from 'react-native-image-picker';
|
|
108
109
|
|
|
109
110
|
export default function App() {
|
|
111
|
+
const listenerSubscription = useRef<Record<string, EventSubscription>>({});
|
|
112
|
+
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
listenerSubscription.current.onLoad = NativeVideoTrim.onLoad(
|
|
115
|
+
({ duration }) => console.log('onLoad', duration)
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
listenerSubscription.current.onStartTrimming =
|
|
119
|
+
NativeVideoTrim.onStartTrimming(() => console.log('onStartTrimming'));
|
|
120
|
+
|
|
121
|
+
listenerSubscription.current.onCancelTrimming =
|
|
122
|
+
NativeVideoTrim.onCancelTrimming(() => console.log('onCancelTrimming'));
|
|
123
|
+
listenerSubscription.current.onCancel = NativeVideoTrim.onCancel(() =>
|
|
124
|
+
console.log('onCancel')
|
|
125
|
+
);
|
|
126
|
+
listenerSubscription.current.onHide = NativeVideoTrim.onHide(() =>
|
|
127
|
+
console.log('onHide')
|
|
128
|
+
);
|
|
129
|
+
listenerSubscription.current.onShow = NativeVideoTrim.onShow(() =>
|
|
130
|
+
console.log('onShow')
|
|
131
|
+
);
|
|
132
|
+
listenerSubscription.current.onFinishTrimming =
|
|
133
|
+
NativeVideoTrim.onFinishTrimming(
|
|
134
|
+
({ outputPath, startTime, endTime, duration }) =>
|
|
135
|
+
console.log(
|
|
136
|
+
'onFinishTrimming',
|
|
137
|
+
`outputPath: ${outputPath}, startTime: ${startTime}, endTime: ${endTime}, duration: ${duration}`
|
|
138
|
+
)
|
|
139
|
+
);
|
|
140
|
+
listenerSubscription.current.onLog = NativeVideoTrim.onLog(
|
|
141
|
+
({ level, message, sessionId }) =>
|
|
142
|
+
console.log(
|
|
143
|
+
'onLog',
|
|
144
|
+
`level: ${level}, message: ${message}, sessionId: ${sessionId}`
|
|
145
|
+
)
|
|
146
|
+
);
|
|
147
|
+
listenerSubscription.current.onStatistics = NativeVideoTrim.onStatistics(
|
|
148
|
+
({
|
|
149
|
+
sessionId,
|
|
150
|
+
videoFrameNumber,
|
|
151
|
+
videoFps,
|
|
152
|
+
videoQuality,
|
|
153
|
+
size,
|
|
154
|
+
time,
|
|
155
|
+
bitrate,
|
|
156
|
+
speed,
|
|
157
|
+
}) =>
|
|
158
|
+
console.log(
|
|
159
|
+
'onStatistics',
|
|
160
|
+
`sessionId: ${sessionId}, videoFrameNumber: ${videoFrameNumber}, videoFps: ${videoFps}, videoQuality: ${videoQuality}, size: ${size}, time: ${time}, bitrate: ${bitrate}, speed: ${speed}`
|
|
161
|
+
)
|
|
162
|
+
);
|
|
163
|
+
listenerSubscription.current.onError = NativeVideoTrim.onError(
|
|
164
|
+
({ message, errorCode }) =>
|
|
165
|
+
console.log('onError', `message: ${message}, errorCode: ${errorCode}`)
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
return () => {
|
|
169
|
+
listenerSubscription.current.onLoad?.remove();
|
|
170
|
+
listenerSubscription.current.onStartTrimming?.remove();
|
|
171
|
+
listenerSubscription.current.onCancelTrimming?.remove();
|
|
172
|
+
listenerSubscription.current.onCancel?.remove();
|
|
173
|
+
listenerSubscription.current.onHide?.remove();
|
|
174
|
+
listenerSubscription.current.onShow?.remove();
|
|
175
|
+
listenerSubscription.current.onFinishTrimming?.remove();
|
|
176
|
+
listenerSubscription.current.onLog?.remove();
|
|
177
|
+
listenerSubscription.current.onStatistics?.remove();
|
|
178
|
+
listenerSubscription.current.onError?.remove();
|
|
179
|
+
listenerSubscription.current = {};
|
|
180
|
+
};
|
|
181
|
+
});
|
|
182
|
+
|
|
110
183
|
return (
|
|
111
184
|
<View style={styles.container}>
|
|
112
185
|
<TouchableOpacity
|
|
@@ -122,11 +195,7 @@ export default function App() {
|
|
|
122
195
|
|
|
123
196
|
showEditor(result.assets![0]?.uri || '', {
|
|
124
197
|
maxDuration: 20,
|
|
125
|
-
}
|
|
126
|
-
(eventName, payload) => {
|
|
127
|
-
console.log('Event:', eventName, 'Payload:', payload);
|
|
128
|
-
}
|
|
129
|
-
);
|
|
198
|
+
});
|
|
130
199
|
}}
|
|
131
200
|
style={{ padding: 10, backgroundColor: 'red' }}
|
|
132
201
|
>
|
|
@@ -159,7 +228,7 @@ const styles = StyleSheet.create({
|
|
|
159
228
|
|
|
160
229
|
# Methods
|
|
161
230
|
|
|
162
|
-
## showEditor(videoPath: string, config?: EditorConfig
|
|
231
|
+
## showEditor(videoPath: string, config?: EditorConfig) => void)
|
|
163
232
|
Main method to show Video Editor UI.
|
|
164
233
|
|
|
165
234
|
*Params*:
|
|
@@ -211,6 +280,8 @@ Main method to show Video Editor UI.
|
|
|
211
280
|
- `alertOnFailTitle` (`default = "Error"`)
|
|
212
281
|
- `alertOnFailMessage` (`default = "Fail to load media. Possibly invalid file or no network connection"`)
|
|
213
282
|
- `alertOnFailCloseText` (`default = "Close"`)
|
|
283
|
+
- `enableRotation` (`default = false`)
|
|
284
|
+
- `rotationAngle` (`default = 0`)
|
|
214
285
|
|
|
215
286
|
If `saveToPhoto = true`, you must ensure that you have request permission to write to photo/gallery
|
|
216
287
|
- For Android: you need to have `<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />` in AndroidManifest.xml
|
|
@@ -241,6 +312,10 @@ If you face issue when building Android app related to `file_paths`, then you ma
|
|
|
241
312
|
</paths>
|
|
242
313
|
```
|
|
243
314
|
|
|
315
|
+
## trim(url: string, options: TrimOptions): Promise<string>
|
|
316
|
+
|
|
317
|
+
Directly trim a file without showing editor
|
|
318
|
+
|
|
244
319
|
## isValidFile(videoPath: string)
|
|
245
320
|
|
|
246
321
|
This method is to check if a path is a valid video/audio
|
|
@@ -263,75 +338,15 @@ Delete a file in app storage. Return `true` if success
|
|
|
263
338
|
## showEditor
|
|
264
339
|
|
|
265
340
|
```ts
|
|
266
|
-
showEditor('file', config
|
|
267
|
-
console.log(eventName, payload)
|
|
268
|
-
})
|
|
341
|
+
showEditor('file', config)
|
|
269
342
|
```
|
|
270
343
|
|
|
271
344
|
## closeEditor
|
|
272
345
|
|
|
273
346
|
```ts
|
|
274
|
-
closeEditor(
|
|
275
|
-
console.log('Editor closed')
|
|
276
|
-
})
|
|
347
|
+
closeEditor()
|
|
277
348
|
```
|
|
278
349
|
|
|
279
|
-
|
|
280
|
-
# Events (Old arch)
|
|
281
|
-
To listen for events you interest, do the following:
|
|
282
|
-
```js
|
|
283
|
-
useEffect(() => {
|
|
284
|
-
const eventEmitter = new NativeEventEmitter(NativeModules.VideoTrim);
|
|
285
|
-
const subscription = eventEmitter.addListener('VideoTrim', (event) => {
|
|
286
|
-
switch (event.name) {
|
|
287
|
-
case 'onLoad': {
|
|
288
|
-
console.log('onLoadListener', event);
|
|
289
|
-
break;
|
|
290
|
-
}
|
|
291
|
-
case 'onShow': {
|
|
292
|
-
console.log('onShowListener', event);
|
|
293
|
-
break;
|
|
294
|
-
}
|
|
295
|
-
case 'onHide': {
|
|
296
|
-
console.log('onHide', event);
|
|
297
|
-
break;
|
|
298
|
-
}
|
|
299
|
-
case 'onStartTrimming': {
|
|
300
|
-
console.log('onStartTrimming', event);
|
|
301
|
-
break;
|
|
302
|
-
}
|
|
303
|
-
case 'onFinishTrimming': {
|
|
304
|
-
console.log('onFinishTrimming', event);
|
|
305
|
-
break;
|
|
306
|
-
}
|
|
307
|
-
case 'onCancelTrimming': {
|
|
308
|
-
console.log('onCancelTrimming', event);
|
|
309
|
-
break;
|
|
310
|
-
}
|
|
311
|
-
case 'onCancel': {
|
|
312
|
-
console.log('onCancel', event);
|
|
313
|
-
break;
|
|
314
|
-
}
|
|
315
|
-
case 'onError': {
|
|
316
|
-
console.log('onError', event);
|
|
317
|
-
break;
|
|
318
|
-
}
|
|
319
|
-
case 'onLog': {
|
|
320
|
-
console.log('onLog', event);
|
|
321
|
-
break;
|
|
322
|
-
}
|
|
323
|
-
case 'onStatistics': {
|
|
324
|
-
console.log('onStatistics', event);
|
|
325
|
-
break;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
return () => {
|
|
331
|
-
subscription.remove();
|
|
332
|
-
};
|
|
333
|
-
}, []);
|
|
334
|
-
```
|
|
335
350
|
# Audio support
|
|
336
351
|
<div align="left">
|
|
337
352
|
<img src="images/audio_android.jpg" width="200" />
|
|
@@ -363,14 +378,40 @@ If there's error while loading media, there'll be a prompt
|
|
|
363
378
|
|
|
364
379
|
Related props: `alertOnFailToLoad, alertOnFailTitle, alertOnFailMessage, alertOnFailCloseText`
|
|
365
380
|
|
|
381
|
+
# Rotation
|
|
382
|
+
|
|
383
|
+
To trim & rotate video you can pass `enableRotation` and `rotationAngle` to `showEditor`/`trim`. But note that it doesn't re-encode the video, instead the lib uses `display_rotation` metadata from ffmpeg, and some players/platforms may show differently.
|
|
384
|
+
|
|
385
|
+
# Use FFMPEG HTTPS version
|
|
386
|
+
|
|
387
|
+
If you want to trim a remote file, you need to use `https` version (default is `min` which does not support remote file).
|
|
388
|
+
|
|
389
|
+
Do the following:
|
|
390
|
+
|
|
391
|
+
```
|
|
392
|
+
// android/build.gradle
|
|
393
|
+
buildscript {
|
|
394
|
+
ext {
|
|
395
|
+
VideoTrim_ffmpeg_package=https
|
|
396
|
+
|
|
397
|
+
// optional: VideoTrim_ffmpeg_version=6.0.1
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// ios
|
|
402
|
+
FFMPEGKIT_PACKAGE=https FFMPEG_KIT_PACKAGE_VERSION=6.0 pod install
|
|
403
|
+
```
|
|
404
|
+
|
|
366
405
|
# Android: update SDK version
|
|
367
406
|
You can override sdk version to use any version in your `android/build.gradle` > `buildscript` > `ext`
|
|
368
407
|
```gradle
|
|
369
408
|
buildscript {
|
|
370
409
|
ext {
|
|
371
|
-
|
|
372
|
-
VideoTrim_minSdkVersion
|
|
373
|
-
VideoTrim_targetSdkVersion
|
|
410
|
+
VideoTrim_kotlinVersion=2.0.21
|
|
411
|
+
VideoTrim_minSdkVersion=24
|
|
412
|
+
VideoTrim_targetSdkVersion=34
|
|
413
|
+
VideoTrim_compileSdkVersion=35
|
|
414
|
+
VideoTrim_ndkVersion=27.1.12297006
|
|
374
415
|
}
|
|
375
416
|
}
|
|
376
417
|
```
|
package/VideoTrim.podspec
CHANGED
|
@@ -13,12 +13,12 @@ Pod::Spec.new do |s|
|
|
|
13
13
|
s.platforms = { :ios => min_ios_version_supported }
|
|
14
14
|
s.source = { :git => "https://github.com/maitrungduc1410/react-native-video-trim.git", :tag => "#{s.version}" }
|
|
15
15
|
|
|
16
|
-
s.source_files = "ios/**/*.{h,m,mm,
|
|
16
|
+
s.source_files = "ios/**/*.{h,m,mm,cpp}"
|
|
17
|
+
s.private_header_files = "ios/**/*.h"
|
|
17
18
|
|
|
18
|
-
s.dependency
|
|
19
|
+
s.dependency "ffmpeg-mobile-#{ENV['FFMPEGKIT_PACKAGE'] || 'min'}", ENV['FFMPEGKIT_PACKAGE_VERSION'] || '~> 6.0'
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
add_nitrogen_files(s)
|
|
21
|
+
s.frameworks = 'AVFoundation', 'AVKit', 'UIKit', 'Photos'
|
|
22
22
|
|
|
23
23
|
install_modules_dependencies(s)
|
|
24
24
|
end
|
package/android/build.gradle
CHANGED
|
@@ -15,14 +15,9 @@ buildscript {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
def reactNativeArchitectures() {
|
|
19
|
-
def value = rootProject.getProperties().get("reactNativeArchitectures")
|
|
20
|
-
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
21
|
-
}
|
|
22
18
|
|
|
23
19
|
apply plugin: "com.android.library"
|
|
24
20
|
apply plugin: "kotlin-android"
|
|
25
|
-
apply from: '../nitrogen/generated/android/videotrim+autolinking.gradle'
|
|
26
21
|
|
|
27
22
|
apply plugin: "com.facebook.react"
|
|
28
23
|
|
|
@@ -30,63 +25,26 @@ def getExtOrIntegerDefault(name) {
|
|
|
30
25
|
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["VideoTrim_" + name]).toInteger()
|
|
31
26
|
}
|
|
32
27
|
|
|
28
|
+
def getPackageNameOrDefault() {
|
|
29
|
+
return rootProject.ext.has("VideoTrim_ffmpeg_package") ? rootProject.ext.get("VideoTrim_ffmpeg_package") : project.properties["VideoTrim_ffmpeg_package"]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
def getPackageVersionOrDefault() {
|
|
33
|
+
return rootProject.ext.has("VideoTrim_ffmpeg_version") ? rootProject.ext.get("VideoTrim_ffmpeg_version") : project.properties["VideoTrim_ffmpeg_version"]
|
|
34
|
+
}
|
|
35
|
+
|
|
33
36
|
android {
|
|
34
|
-
namespace "com.
|
|
37
|
+
namespace "com.videotrim"
|
|
35
38
|
|
|
36
39
|
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
37
40
|
|
|
38
41
|
defaultConfig {
|
|
39
42
|
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
40
43
|
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
41
|
-
|
|
42
|
-
externalNativeBuild {
|
|
43
|
-
cmake {
|
|
44
|
-
cppFlags "-frtti -fexceptions -Wall -fstack-protector-all"
|
|
45
|
-
arguments "-DANDROID_STL=c++_shared"
|
|
46
|
-
abiFilters (*reactNativeArchitectures())
|
|
47
|
-
|
|
48
|
-
buildTypes {
|
|
49
|
-
debug {
|
|
50
|
-
cppFlags "-O1 -g"
|
|
51
|
-
}
|
|
52
|
-
release {
|
|
53
|
-
cppFlags "-O2"
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
externalNativeBuild {
|
|
61
|
-
cmake {
|
|
62
|
-
path "CMakeLists.txt"
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
packagingOptions {
|
|
67
|
-
excludes = [
|
|
68
|
-
"META-INF",
|
|
69
|
-
"META-INF/**",
|
|
70
|
-
"**/libc++_shared.so",
|
|
71
|
-
"**/libfbjni.so",
|
|
72
|
-
"**/libjsi.so",
|
|
73
|
-
"**/libfolly_json.so",
|
|
74
|
-
"**/libfolly_runtime.so",
|
|
75
|
-
"**/libglog.so",
|
|
76
|
-
"**/libhermes.so",
|
|
77
|
-
"**/libhermes-executor-debug.so",
|
|
78
|
-
"**/libhermes_executor.so",
|
|
79
|
-
"**/libreactnative.so",
|
|
80
|
-
"**/libreactnativejni.so",
|
|
81
|
-
"**/libturbomodulejsijni.so",
|
|
82
|
-
"**/libreact_nativemodule_core.so",
|
|
83
|
-
"**/libjscexecutor.so"
|
|
84
|
-
]
|
|
85
44
|
}
|
|
86
45
|
|
|
87
46
|
buildFeatures {
|
|
88
47
|
buildConfig true
|
|
89
|
-
prefab true
|
|
90
48
|
}
|
|
91
49
|
|
|
92
50
|
buildTypes {
|
|
@@ -124,8 +82,11 @@ def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
|
124
82
|
dependencies {
|
|
125
83
|
implementation "com.facebook.react:react-android"
|
|
126
84
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
127
|
-
implementation
|
|
128
|
-
|
|
129
|
-
implementation 'io.github.maitrungduc1410:ffmpeg-kit-min:6.0.0'
|
|
85
|
+
implementation 'io.github.maitrungduc1410:ffmpeg-kit-' + getPackageNameOrDefault() +':' + getPackageVersionOrDefault()
|
|
130
86
|
}
|
|
131
87
|
|
|
88
|
+
react {
|
|
89
|
+
jsRootDir = file("../src/")
|
|
90
|
+
libraryName = "VideoTrim"
|
|
91
|
+
codegenJavaPackageName = "com.videotrim"
|
|
92
|
+
}
|