react-native-video-trim 3.0.10 → 4.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 +46 -57
- package/VideoTrim.podspec +24 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +76 -51
- package/android/gradle.properties +5 -5
- package/android/src/main/AndroidManifest.xml +4 -2
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/videotrim/VideoTrim.kt +629 -0
- package/android/src/main/java/com/margelo/nitro/videotrim/VideoTrimPackage.kt +22 -0
- package/android/src/main/java/com/{videotrim → margelo/nitro/videotrim}/enums/ErrorCode.java +1 -1
- package/android/src/main/java/com/{videotrim → margelo/nitro/videotrim}/interfaces/IVideoTrimmerView.java +1 -1
- package/android/src/main/java/com/{videotrim → margelo/nitro/videotrim}/interfaces/VideoTrimListener.java +6 -5
- package/android/src/main/java/com/{videotrim → margelo/nitro/videotrim}/utils/MediaMetadataUtil.java +1 -1
- package/android/src/main/java/com/{videotrim → margelo/nitro/videotrim}/utils/StorageUtil.java +3 -1
- package/android/src/main/java/com/{videotrim → margelo/nitro/videotrim}/utils/VideoTrimmerUtil.java +22 -20
- package/android/src/main/java/com/{videotrim → margelo/nitro/videotrim}/widgets/VideoTrimmerView.java +38 -66
- package/ios/AssetLoader.swift +2 -2
- package/ios/ErrorCode.swift +2 -2
- package/ios/ProgressAlertController.swift +2 -2
- package/ios/VideoTrim.swift +48 -838
- package/ios/VideoTrimImpl.swift +860 -0
- package/ios/VideoTrimmer.swift +2 -3
- package/ios/VideoTrimmerThumb.swift +33 -26
- package/ios/VideoTrimmerViewController.swift +47 -28
- package/lib/module/VideoTrim.nitro.js +4 -0
- package/lib/module/VideoTrim.nitro.js.map +1 -0
- package/lib/module/index.js +71 -22
- package/lib/module/index.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/{index.d.ts → src/VideoTrim.nitro.d.ts} +63 -89
- package/lib/typescript/src/VideoTrim.nitro.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +41 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/nitrogen/generated/android/c++/JEditorConfig.hpp +229 -0
- package/nitrogen/generated/android/c++/JFileValidationResult.hpp +61 -0
- package/nitrogen/generated/android/c++/JFunc_void.hpp +74 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__string_std__unordered_map_std__string__std__string_.hpp +89 -0
- package/nitrogen/generated/android/c++/JHybridVideoTrimSpec.cpp +131 -0
- package/nitrogen/generated/android/c++/JHybridVideoTrimSpec.hpp +67 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/videotrim/EditorConfig.kt +70 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/videotrim/FileValidationResult.kt +28 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/videotrim/Func_void.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/videotrim/Func_void_std__string_std__unordered_map_std__string__std__string_.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/videotrim/HybridVideoTrimSpec.kt +82 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/videotrim/videotrimOnLoad.kt +35 -0
- package/nitrogen/generated/android/videotrim+autolinking.cmake +78 -0
- package/nitrogen/generated/android/videotrim+autolinking.gradle +27 -0
- package/nitrogen/generated/android/videotrimOnLoad.cpp +50 -0
- package/nitrogen/generated/android/videotrimOnLoad.hpp +25 -0
- package/nitrogen/generated/ios/VideoTrim+autolinking.rb +60 -0
- package/nitrogen/generated/ios/VideoTrim-Swift-Cxx-Bridge.cpp +88 -0
- package/nitrogen/generated/ios/VideoTrim-Swift-Cxx-Bridge.hpp +331 -0
- package/nitrogen/generated/ios/VideoTrim-Swift-Cxx-Umbrella.hpp +53 -0
- package/nitrogen/generated/ios/VideoTrimAutolinking.mm +33 -0
- package/nitrogen/generated/ios/VideoTrimAutolinking.swift +25 -0
- package/nitrogen/generated/ios/c++/HybridVideoTrimSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridVideoTrimSpecSwift.hpp +116 -0
- package/nitrogen/generated/ios/swift/EditorConfig.swift +519 -0
- package/nitrogen/generated/ios/swift/FileValidationResult.swift +57 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_FileValidationResult.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_double.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string_std__unordered_map_std__string__std__string_.swift +54 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_std__string_.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridVideoTrimSpec.swift +53 -0
- package/nitrogen/generated/ios/swift/HybridVideoTrimSpec_cxx.swift +222 -0
- package/nitrogen/generated/shared/c++/EditorConfig.hpp +245 -0
- package/nitrogen/generated/shared/c++/FileValidationResult.hpp +77 -0
- package/nitrogen/generated/shared/c++/HybridVideoTrimSpec.cpp +26 -0
- package/nitrogen/generated/shared/c++/HybridVideoTrimSpec.hpp +76 -0
- package/package.json +75 -71
- package/src/VideoTrim.nitro.ts +244 -0
- package/src/index.tsx +87 -258
- package/android/src/main/AndroidManifestDeprecated.xml +0 -3
- package/android/src/main/java/com/videotrim/VideoTrimModule.java +0 -603
- package/android/src/main/java/com/videotrim/VideoTrimPackage.java +0 -28
- package/ios/VideoTrim-Bridging-Header.h +0 -2
- package/ios/VideoTrim.mm +0 -17
- package/ios/VideoTrim.xcodeproj/project.pbxproj +0 -283
- package/lib/commonjs/index.js +0 -87
- package/lib/commonjs/index.js.map +0 -1
- package/lib/typescript/index.d.ts.map +0 -1
- package/react-native-video-trim.podspec +0 -43
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
+
|
|
3
|
+
export interface EditorConfig {
|
|
4
|
+
/**
|
|
5
|
+
* Enable haptic feedback
|
|
6
|
+
* @default true
|
|
7
|
+
*/
|
|
8
|
+
enableHapticFeedback: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Save the output file to Photos Library. Only video is supported. Note that you have to make sure you have permission to save to Photos Library.
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
saveToPhoto: boolean;
|
|
14
|
+
maxDuration: number;
|
|
15
|
+
/**
|
|
16
|
+
* Minimum duration for trimmer
|
|
17
|
+
* @default 1000
|
|
18
|
+
*/
|
|
19
|
+
minDuration: number;
|
|
20
|
+
/**
|
|
21
|
+
* Cancel button text
|
|
22
|
+
* @default "Cancel"
|
|
23
|
+
*/
|
|
24
|
+
cancelButtonText: string;
|
|
25
|
+
/**
|
|
26
|
+
* Save button text
|
|
27
|
+
* @default "Save"
|
|
28
|
+
*/
|
|
29
|
+
saveButtonText: string;
|
|
30
|
+
/**
|
|
31
|
+
* Enable cancel dialog
|
|
32
|
+
* @default true
|
|
33
|
+
*/
|
|
34
|
+
enableCancelDialog: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Cancel dialog title
|
|
37
|
+
* @default "Warning!"
|
|
38
|
+
*/
|
|
39
|
+
cancelDialogTitle: string;
|
|
40
|
+
/**
|
|
41
|
+
* Cancel dialog message
|
|
42
|
+
* @default "Are you sure want to cancel?"
|
|
43
|
+
*/
|
|
44
|
+
cancelDialogMessage: string;
|
|
45
|
+
/**
|
|
46
|
+
* Cancel dialog cancel text
|
|
47
|
+
* @default "Close"
|
|
48
|
+
*/
|
|
49
|
+
cancelDialogCancelText: string;
|
|
50
|
+
/**
|
|
51
|
+
* Cancel dialog confirm text
|
|
52
|
+
* @default "Proceed"
|
|
53
|
+
*/
|
|
54
|
+
cancelDialogConfirmText: string;
|
|
55
|
+
/**
|
|
56
|
+
* Enable save dialog
|
|
57
|
+
* @default true
|
|
58
|
+
*/
|
|
59
|
+
enableSaveDialog: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Save dialog title
|
|
62
|
+
* @default "Confirmation!"
|
|
63
|
+
*/
|
|
64
|
+
saveDialogTitle: string;
|
|
65
|
+
/**
|
|
66
|
+
* Save dialog message
|
|
67
|
+
* @default "Are you sure want to save?"
|
|
68
|
+
*/
|
|
69
|
+
saveDialogMessage: string;
|
|
70
|
+
/**
|
|
71
|
+
* Save dialog cancel text
|
|
72
|
+
* @default "Close"
|
|
73
|
+
*/
|
|
74
|
+
saveDialogCancelText: string;
|
|
75
|
+
/**
|
|
76
|
+
* Save dialog confirm text
|
|
77
|
+
* @default "Proceed"
|
|
78
|
+
*/
|
|
79
|
+
saveDialogConfirmText: string;
|
|
80
|
+
/**
|
|
81
|
+
* Trimming text
|
|
82
|
+
* @default "Trimming video..."
|
|
83
|
+
*/
|
|
84
|
+
trimmingText: string;
|
|
85
|
+
/**
|
|
86
|
+
* By default, on iOS the editor will be presented as a modal. If you want to present it as a full screen modal, set this to `true`.
|
|
87
|
+
* @default false
|
|
88
|
+
*/
|
|
89
|
+
fullScreenModalIOS: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Type of the file to edit. If video file, recommend to use `video`. If audio file, recommend to use `audio`.
|
|
92
|
+
* @default "video"
|
|
93
|
+
*/
|
|
94
|
+
type: string;
|
|
95
|
+
/**
|
|
96
|
+
* Output file extension. If video file, recommend to use `mp4` or `mov`. If audio file, recommend to use `wav` or `m4a`.
|
|
97
|
+
* @default "mp4"
|
|
98
|
+
* @example "mp4", "mov", "wav", "m4a", "3gp", "avi", "mkv", "flv", "wmv", "webm"
|
|
99
|
+
*/
|
|
100
|
+
outputExt: string;
|
|
101
|
+
/**
|
|
102
|
+
* Whether to open Documents app after finish editing
|
|
103
|
+
* @default false
|
|
104
|
+
*/
|
|
105
|
+
openDocumentsOnFinish: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Whether to open Share Sheet after finish editing
|
|
108
|
+
* @default false
|
|
109
|
+
*/
|
|
110
|
+
openShareSheetOnFinish: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Remove the file after saved to Photos Library
|
|
113
|
+
* @default false
|
|
114
|
+
*/
|
|
115
|
+
removeAfterSavedToPhoto: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Remove the file after failed to save to Photos Library
|
|
118
|
+
* @default false
|
|
119
|
+
*/
|
|
120
|
+
removeAfterFailedToSavePhoto: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Remove the file after saved to Documents app
|
|
123
|
+
* @default false
|
|
124
|
+
*/
|
|
125
|
+
removeAfterSavedToDocuments: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Remove the file after failed to save to Documents app
|
|
128
|
+
* @default false
|
|
129
|
+
*/
|
|
130
|
+
removeAfterFailedToSaveDocuments: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Remove the file after shared to other apps. Currently only support iOS, on Android there's no way to detect if the file is shared or not.
|
|
133
|
+
* @default false
|
|
134
|
+
*/
|
|
135
|
+
removeAfterShared: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Remove the file after failed to share to other apps. Currently only support iOS, on Android there's no way to detect if the file is shared or not.
|
|
138
|
+
* @default false
|
|
139
|
+
*/
|
|
140
|
+
removeAfterFailedToShare: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Whether to enable autoplay on load
|
|
143
|
+
*/
|
|
144
|
+
autoplay: boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Jump to position on load in milliseconds
|
|
147
|
+
* @default `undefined` (beginning of the video)
|
|
148
|
+
*/
|
|
149
|
+
jumpToPositionOnLoad: number;
|
|
150
|
+
/**
|
|
151
|
+
* Whether to close the editor when finish editing
|
|
152
|
+
* @default true
|
|
153
|
+
*/
|
|
154
|
+
closeWhenFinish: boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Enable cancel trimming
|
|
157
|
+
* @default true
|
|
158
|
+
*/
|
|
159
|
+
enableCancelTrimming: boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Cancel trimming button text
|
|
162
|
+
* @default "Cancel"
|
|
163
|
+
*/
|
|
164
|
+
cancelTrimmingButtonText: string;
|
|
165
|
+
/**
|
|
166
|
+
* Enable cancel trimming dialog
|
|
167
|
+
* @default true
|
|
168
|
+
*/
|
|
169
|
+
enableCancelTrimmingDialog: boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Cancel trimming dialog title
|
|
172
|
+
* @default "Warning!"
|
|
173
|
+
*/
|
|
174
|
+
cancelTrimmingDialogTitle: string;
|
|
175
|
+
/**
|
|
176
|
+
* Cancel trimming dialog message
|
|
177
|
+
* @default "Are you sure want to cancel trimming?"
|
|
178
|
+
*/
|
|
179
|
+
cancelTrimmingDialogMessage: string;
|
|
180
|
+
/**
|
|
181
|
+
* Cancel trimming dialog cancel text
|
|
182
|
+
* @default "Close"
|
|
183
|
+
*/
|
|
184
|
+
cancelTrimmingDialogCancelText: string;
|
|
185
|
+
/**
|
|
186
|
+
* Cancel trimming dialog confirm text
|
|
187
|
+
* @default "Proceed"
|
|
188
|
+
*/
|
|
189
|
+
cancelTrimmingDialogConfirmText: string;
|
|
190
|
+
/**
|
|
191
|
+
* Header text
|
|
192
|
+
*/
|
|
193
|
+
headerText: string;
|
|
194
|
+
/**
|
|
195
|
+
* Header text size
|
|
196
|
+
* @default 16
|
|
197
|
+
*/
|
|
198
|
+
headerTextSize: number;
|
|
199
|
+
/**
|
|
200
|
+
* Header text color
|
|
201
|
+
* @default white
|
|
202
|
+
*/
|
|
203
|
+
headerTextColor: number;
|
|
204
|
+
/**
|
|
205
|
+
* Alert on fail to load media
|
|
206
|
+
* @default true
|
|
207
|
+
*/
|
|
208
|
+
alertOnFailToLoad: boolean;
|
|
209
|
+
/**
|
|
210
|
+
* Alert on fail to load media title
|
|
211
|
+
* @default "Error"
|
|
212
|
+
*/
|
|
213
|
+
alertOnFailTitle: string;
|
|
214
|
+
/**
|
|
215
|
+
* Alert on fail to load media message
|
|
216
|
+
* @default "Fail to load media. Possibly invalid file or no network connection"
|
|
217
|
+
*/
|
|
218
|
+
alertOnFailMessage: string;
|
|
219
|
+
/**
|
|
220
|
+
* Alert on fail to load media close text
|
|
221
|
+
* @default "Close"
|
|
222
|
+
*/
|
|
223
|
+
alertOnFailCloseText: string;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export interface FileValidationResult {
|
|
227
|
+
isValid: boolean;
|
|
228
|
+
fileType: string;
|
|
229
|
+
duration: number;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export interface VideoTrim
|
|
233
|
+
extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> {
|
|
234
|
+
showEditor(
|
|
235
|
+
filePath: string,
|
|
236
|
+
config: EditorConfig,
|
|
237
|
+
onEvent: (eventName: string, payload: Record<string, string>) => void // currently nitro modules will fail if there are 2 optional callbacks, to make if work, we need to pass the onEvent as the last parameter
|
|
238
|
+
): void;
|
|
239
|
+
listFiles(): Promise<string[]>;
|
|
240
|
+
cleanFiles(): Promise<number>;
|
|
241
|
+
deleteFile(filePath: string): Promise<boolean>;
|
|
242
|
+
closeEditor(onComplete: () => void): void;
|
|
243
|
+
isValidFile(url: string): Promise<FileValidationResult>;
|
|
244
|
+
}
|
package/src/index.tsx
CHANGED
|
@@ -1,255 +1,70 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from '
|
|
1
|
+
import { NitroModules } from 'react-native-nitro-modules';
|
|
2
|
+
import type {
|
|
3
|
+
EditorConfig,
|
|
4
|
+
FileValidationResult,
|
|
5
|
+
VideoTrim,
|
|
6
|
+
} from './VideoTrim.nitro';
|
|
7
|
+
import { processColor } from 'react-native';
|
|
7
8
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
11
|
-
'- You rebuilt the app after installing the package\n' +
|
|
12
|
-
'- You are not using Expo Go\n';
|
|
9
|
+
const VideoTrimHybridObject =
|
|
10
|
+
NitroModules.createHybridObject<VideoTrim>('VideoTrim');
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
cancelDialogMessage?: string;
|
|
67
|
-
/**
|
|
68
|
-
* Cancel dialog cancel text
|
|
69
|
-
* @default "Close"
|
|
70
|
-
*/
|
|
71
|
-
cancelDialogCancelText?: string;
|
|
72
|
-
/**
|
|
73
|
-
* Cancel dialog confirm text
|
|
74
|
-
* @default "Proceed"
|
|
75
|
-
*/
|
|
76
|
-
cancelDialogConfirmText?: string;
|
|
77
|
-
/**
|
|
78
|
-
* Enable save dialog
|
|
79
|
-
* @default true
|
|
80
|
-
*/
|
|
81
|
-
enableSaveDialog?: boolean;
|
|
82
|
-
/**
|
|
83
|
-
* Save dialog title
|
|
84
|
-
* @default "Confirmation!"
|
|
85
|
-
*/
|
|
86
|
-
saveDialogTitle?: string;
|
|
87
|
-
/**
|
|
88
|
-
* Save dialog message
|
|
89
|
-
* @default "Are you sure want to save?"
|
|
90
|
-
*/
|
|
91
|
-
saveDialogMessage?: string;
|
|
92
|
-
/**
|
|
93
|
-
* Save dialog cancel text
|
|
94
|
-
* @default "Close"
|
|
95
|
-
*/
|
|
96
|
-
saveDialogCancelText?: string;
|
|
97
|
-
/**
|
|
98
|
-
* Save dialog confirm text
|
|
99
|
-
* @default "Proceed"
|
|
100
|
-
*/
|
|
101
|
-
saveDialogConfirmText?: string;
|
|
102
|
-
/**
|
|
103
|
-
* Trimming text
|
|
104
|
-
* @default "Trimming video..."
|
|
105
|
-
*/
|
|
106
|
-
trimmingText?: string;
|
|
107
|
-
/**
|
|
108
|
-
* By default, on iOS the editor will be presented as a modal. If you want to present it as a full screen modal, set this to `true`.
|
|
109
|
-
* @default false
|
|
110
|
-
*/
|
|
111
|
-
fullScreenModalIOS?: boolean;
|
|
112
|
-
/**
|
|
113
|
-
* Type of the file to edit. If video file, recommend to use `video`. If audio file, recommend to use `audio`.
|
|
114
|
-
* @default "video"
|
|
115
|
-
*/
|
|
116
|
-
type?: 'video' | 'audio';
|
|
117
|
-
/**
|
|
118
|
-
* Output file extension. If video file, recommend to use `mp4` or `mov`. If audio file, recommend to use `wav` or `m4a`.
|
|
119
|
-
* @default "mp4"
|
|
120
|
-
* @example "mp4", "mov", "wav", "m4a", "3gp", "avi", "mkv", "flv", "wmv", "webm"
|
|
121
|
-
*/
|
|
122
|
-
outputExt?: string;
|
|
123
|
-
/**
|
|
124
|
-
* Whether to open Documents app after finish editing
|
|
125
|
-
* @default false
|
|
126
|
-
*/
|
|
127
|
-
openDocumentsOnFinish?: boolean;
|
|
128
|
-
/**
|
|
129
|
-
* Whether to open Share Sheet after finish editing
|
|
130
|
-
* @default false
|
|
131
|
-
*/
|
|
132
|
-
openShareSheetOnFinish?: boolean;
|
|
133
|
-
/**
|
|
134
|
-
* Remove the file after saved to Photos Library
|
|
135
|
-
* @default false
|
|
136
|
-
*/
|
|
137
|
-
removeAfterSavedToPhoto?: boolean;
|
|
138
|
-
/**
|
|
139
|
-
* Remove the file after failed to save to Photos Library
|
|
140
|
-
* @default false
|
|
141
|
-
*/
|
|
142
|
-
removeAfterFailedToSavePhoto?: boolean;
|
|
143
|
-
/**
|
|
144
|
-
* Remove the file after saved to Documents app
|
|
145
|
-
* @default false
|
|
146
|
-
*/
|
|
147
|
-
removeAfterSavedToDocuments?: boolean;
|
|
148
|
-
/**
|
|
149
|
-
* Remove the file after failed to save to Documents app
|
|
150
|
-
* @default false
|
|
151
|
-
*/
|
|
152
|
-
removeAfterFailedToSaveDocuments?: boolean;
|
|
153
|
-
/**
|
|
154
|
-
* Remove the file after shared to other apps. Currently only support iOS, on Android there's no way to detect if the file is shared or not.
|
|
155
|
-
* @default false
|
|
156
|
-
*/
|
|
157
|
-
removeAfterShared?: boolean;
|
|
158
|
-
/**
|
|
159
|
-
* Remove the file after failed to share to other apps. Currently only support iOS, on Android there's no way to detect if the file is shared or not.
|
|
160
|
-
* @default false
|
|
161
|
-
*/
|
|
162
|
-
removeAfterFailedToShare?: boolean;
|
|
163
|
-
/**
|
|
164
|
-
* Whether to enable autoplay on load
|
|
165
|
-
*/
|
|
166
|
-
autoplay?: boolean;
|
|
167
|
-
/**
|
|
168
|
-
* Jump to position on load in milliseconds
|
|
169
|
-
* @default `undefined` (beginning of the video)
|
|
170
|
-
*/
|
|
171
|
-
jumpToPositionOnLoad?: number;
|
|
172
|
-
/**
|
|
173
|
-
* Whether to close the editor when finish editing
|
|
174
|
-
* @default true
|
|
175
|
-
*/
|
|
176
|
-
closeWhenFinish?: boolean;
|
|
177
|
-
/**
|
|
178
|
-
* Enable cancel trimming
|
|
179
|
-
* @default true
|
|
180
|
-
*/
|
|
181
|
-
enableCancelTrimming?: boolean;
|
|
182
|
-
/**
|
|
183
|
-
* Cancel trimming button text
|
|
184
|
-
* @default "Cancel"
|
|
185
|
-
*/
|
|
186
|
-
cancelTrimmingButtonText?: string;
|
|
187
|
-
/**
|
|
188
|
-
* Enable cancel trimming dialog
|
|
189
|
-
* @default true
|
|
190
|
-
*/
|
|
191
|
-
enableCancelTrimmingDialog?: boolean;
|
|
192
|
-
/**
|
|
193
|
-
* Cancel trimming dialog title
|
|
194
|
-
* @default "Warning!"
|
|
195
|
-
*/
|
|
196
|
-
cancelTrimmingDialogTitle?: string;
|
|
197
|
-
/**
|
|
198
|
-
* Cancel trimming dialog message
|
|
199
|
-
* @default "Are you sure want to cancel trimming?"
|
|
200
|
-
*/
|
|
201
|
-
cancelTrimmingDialogMessage?: string;
|
|
202
|
-
/**
|
|
203
|
-
* Cancel trimming dialog cancel text
|
|
204
|
-
* @default "Close"
|
|
205
|
-
*/
|
|
206
|
-
cancelTrimmingDialogCancelText?: string;
|
|
207
|
-
/**
|
|
208
|
-
* Cancel trimming dialog confirm text
|
|
209
|
-
* @default "Proceed"
|
|
210
|
-
*/
|
|
211
|
-
cancelTrimmingDialogConfirmText?: string;
|
|
212
|
-
/**
|
|
213
|
-
* Header text
|
|
214
|
-
*/
|
|
215
|
-
headerText?: string;
|
|
216
|
-
/**
|
|
217
|
-
* Header text size
|
|
218
|
-
* @default 16
|
|
219
|
-
*/
|
|
220
|
-
headerTextSize?: number;
|
|
221
|
-
/**
|
|
222
|
-
* Header text color
|
|
223
|
-
* @default white
|
|
224
|
-
*/
|
|
225
|
-
headerTextColor?: ColorValue;
|
|
226
|
-
/**
|
|
227
|
-
* Alert on fail to load media
|
|
228
|
-
* @default true
|
|
229
|
-
*/
|
|
230
|
-
alertOnFailToLoad?: boolean;
|
|
231
|
-
/**
|
|
232
|
-
* Alert on fail to load media title
|
|
233
|
-
* @default "Error"
|
|
234
|
-
*/
|
|
235
|
-
alertOnFailTitle?: string;
|
|
236
|
-
/**
|
|
237
|
-
* Alert on fail to load media message
|
|
238
|
-
* @default "Fail to load media. Possibly invalid file or no network connection"
|
|
239
|
-
*/
|
|
240
|
-
alertOnFailMessage?: string;
|
|
241
|
-
/**
|
|
242
|
-
* Alert on fail to load media close text
|
|
243
|
-
* @default "Close"
|
|
244
|
-
*/
|
|
245
|
-
alertOnFailCloseText?: string;
|
|
246
|
-
/**
|
|
247
|
-
* Progress update interval in seconds
|
|
248
|
-
* @default 0.1
|
|
249
|
-
*/
|
|
250
|
-
progressUpdateInterval?: number;
|
|
12
|
+
function createEditorConfig(
|
|
13
|
+
overrides: Partial<EditorConfig> = {}
|
|
14
|
+
): EditorConfig {
|
|
15
|
+
return {
|
|
16
|
+
enableHapticFeedback: true,
|
|
17
|
+
saveToPhoto: false,
|
|
18
|
+
maxDuration: -1, // Adjust default as needed
|
|
19
|
+
minDuration: 1000,
|
|
20
|
+
cancelButtonText: 'Cancel',
|
|
21
|
+
saveButtonText: 'Save',
|
|
22
|
+
enableCancelDialog: true,
|
|
23
|
+
cancelDialogTitle: 'Warning!',
|
|
24
|
+
cancelDialogMessage: 'Are you sure want to cancel?',
|
|
25
|
+
cancelDialogCancelText: 'Close',
|
|
26
|
+
cancelDialogConfirmText: 'Proceed',
|
|
27
|
+
enableSaveDialog: true,
|
|
28
|
+
saveDialogTitle: 'Confirmation!',
|
|
29
|
+
saveDialogMessage: 'Are you sure want to save?',
|
|
30
|
+
saveDialogCancelText: 'Close',
|
|
31
|
+
saveDialogConfirmText: 'Proceed',
|
|
32
|
+
trimmingText: 'Trimming video...',
|
|
33
|
+
fullScreenModalIOS: false,
|
|
34
|
+
type: 'video',
|
|
35
|
+
outputExt: 'mp4',
|
|
36
|
+
openDocumentsOnFinish: false,
|
|
37
|
+
openShareSheetOnFinish: false,
|
|
38
|
+
removeAfterSavedToPhoto: false,
|
|
39
|
+
removeAfterFailedToSavePhoto: false,
|
|
40
|
+
removeAfterSavedToDocuments: false,
|
|
41
|
+
removeAfterFailedToSaveDocuments: false,
|
|
42
|
+
removeAfterShared: false,
|
|
43
|
+
removeAfterFailedToShare: false,
|
|
44
|
+
autoplay: false, // Adjust default as needed
|
|
45
|
+
jumpToPositionOnLoad: -1,
|
|
46
|
+
closeWhenFinish: true,
|
|
47
|
+
enableCancelTrimming: true,
|
|
48
|
+
cancelTrimmingButtonText: 'Cancel',
|
|
49
|
+
enableCancelTrimmingDialog: true,
|
|
50
|
+
cancelTrimmingDialogTitle: 'Warning!',
|
|
51
|
+
cancelTrimmingDialogMessage: 'Are you sure want to cancel trimming?',
|
|
52
|
+
cancelTrimmingDialogCancelText: 'Close',
|
|
53
|
+
cancelTrimmingDialogConfirmText: 'Proceed',
|
|
54
|
+
headerText: '', // Adjust default as needed
|
|
55
|
+
headerTextSize: 16,
|
|
56
|
+
headerTextColor: processColor('white') as number,
|
|
57
|
+
alertOnFailToLoad: true,
|
|
58
|
+
alertOnFailTitle: 'Error',
|
|
59
|
+
alertOnFailMessage:
|
|
60
|
+
'Fail to load media. Possibly invalid file or no network connection',
|
|
61
|
+
alertOnFailCloseText: 'Close',
|
|
62
|
+
...overrides,
|
|
63
|
+
};
|
|
251
64
|
}
|
|
252
65
|
|
|
66
|
+
function noop() {}
|
|
67
|
+
|
|
253
68
|
/**
|
|
254
69
|
* Delete a file
|
|
255
70
|
*
|
|
@@ -257,10 +72,24 @@ export interface EditorConfig {
|
|
|
257
72
|
* @param {EditorConfig} config: editor configuration
|
|
258
73
|
* @returns {void} A **Promise** which resolves `void`
|
|
259
74
|
*/
|
|
260
|
-
export function showEditor(
|
|
75
|
+
export function showEditor(
|
|
76
|
+
filePath: string,
|
|
77
|
+
config: Partial<Omit<EditorConfig, 'headerTextColor'>> & {
|
|
78
|
+
headerTextColor?: string;
|
|
79
|
+
},
|
|
80
|
+
onEvent?: (eventName: string, payload: Record<string, string>) => void
|
|
81
|
+
): void {
|
|
261
82
|
const { headerTextColor } = config;
|
|
262
|
-
const color = processColor(headerTextColor);
|
|
263
|
-
|
|
83
|
+
const color = processColor(headerTextColor || 'white');
|
|
84
|
+
|
|
85
|
+
VideoTrimHybridObject.showEditor(
|
|
86
|
+
filePath,
|
|
87
|
+
createEditorConfig({
|
|
88
|
+
...config,
|
|
89
|
+
headerTextColor: color as any,
|
|
90
|
+
}),
|
|
91
|
+
onEvent || noop
|
|
92
|
+
);
|
|
264
93
|
}
|
|
265
94
|
|
|
266
95
|
/**
|
|
@@ -269,7 +98,7 @@ export function showEditor(filePath: string, config: EditorConfig = {}): void {
|
|
|
269
98
|
* @returns {Promise<string[]>} A **Promise** which resolves to array of files
|
|
270
99
|
*/
|
|
271
100
|
export function listFiles(): Promise<string[]> {
|
|
272
|
-
return
|
|
101
|
+
return VideoTrimHybridObject.listFiles();
|
|
273
102
|
}
|
|
274
103
|
|
|
275
104
|
/**
|
|
@@ -278,7 +107,7 @@ export function listFiles(): Promise<string[]> {
|
|
|
278
107
|
* @returns {Promise} A **Promise** which resolves to number of deleted files
|
|
279
108
|
*/
|
|
280
109
|
export function cleanFiles(): Promise<number> {
|
|
281
|
-
return
|
|
110
|
+
return VideoTrimHybridObject.cleanFiles();
|
|
282
111
|
}
|
|
283
112
|
|
|
284
113
|
/**
|
|
@@ -291,14 +120,14 @@ export function deleteFile(filePath: string): Promise<boolean> {
|
|
|
291
120
|
if (!filePath?.trim().length) {
|
|
292
121
|
throw new Error('File path cannot be empty!');
|
|
293
122
|
}
|
|
294
|
-
return
|
|
123
|
+
return VideoTrimHybridObject.deleteFile(filePath);
|
|
295
124
|
}
|
|
296
125
|
|
|
297
126
|
/**
|
|
298
127
|
* Close editor
|
|
299
128
|
*/
|
|
300
|
-
export function closeEditor(): void {
|
|
301
|
-
return
|
|
129
|
+
export function closeEditor(onComplete?: () => void): void {
|
|
130
|
+
return VideoTrimHybridObject.closeEditor(onComplete || noop);
|
|
302
131
|
}
|
|
303
132
|
|
|
304
133
|
/**
|
|
@@ -306,6 +135,6 @@ export function closeEditor(): void {
|
|
|
306
135
|
*
|
|
307
136
|
* @returns {Promise} A **Promise** which resolves file info if successful
|
|
308
137
|
*/
|
|
309
|
-
export function isValidFile(url: string): Promise<
|
|
310
|
-
return
|
|
138
|
+
export function isValidFile(url: string): Promise<FileValidationResult> {
|
|
139
|
+
return VideoTrimHybridObject.isValidFile(url);
|
|
311
140
|
}
|