react-native-video-trim 6.0.12 → 6.1.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/android/src/main/java/com/videotrim/widgets/VideoTrimmerView.java +2 -2
- package/ios/VideoTrim.swift +7 -6
- package/ios/VideoTrimmerViewController.swift +2 -2
- package/lib/module/NativeVideoTrim.js +25 -0
- package/lib/module/NativeVideoTrim.js.map +1 -1
- package/lib/typescript/src/NativeVideoTrim.d.ts +103 -13
- package/lib/typescript/src/NativeVideoTrim.d.ts.map +1 -1
- package/package.json +5 -2
- package/src/NativeVideoTrim.ts +103 -13
|
@@ -486,11 +486,11 @@ public class VideoTrimmerView extends FrameLayout implements IVideoTrimmerView {
|
|
|
486
486
|
|
|
487
487
|
private void configure(ReadableMap config) {
|
|
488
488
|
if (config.hasKey("maxDuration") && config.getDouble("maxDuration") > 0) {
|
|
489
|
-
mMaxDuration = (long) Math.max(0, config.getDouble("maxDuration")
|
|
489
|
+
mMaxDuration = (long) Math.max(0, config.getDouble("maxDuration"));
|
|
490
490
|
}
|
|
491
491
|
|
|
492
492
|
if (config.hasKey("minDuration") && config.getDouble("minDuration") > 0) {
|
|
493
|
-
mMinDuration = (long) Math.max(1000L, config.getDouble("minDuration")
|
|
493
|
+
mMinDuration = (long) Math.max(1000L, config.getDouble("minDuration"));
|
|
494
494
|
}
|
|
495
495
|
|
|
496
496
|
cancelBtn.setText(config.getString("cancelButtonText"));
|
package/ios/VideoTrim.swift
CHANGED
|
@@ -9,7 +9,6 @@ public class VideoTrim: RCTEventEmitter, AssetLoaderDelegate, UIDocumentPickerDe
|
|
|
9
9
|
// MARK: instance private props
|
|
10
10
|
private var isShowing = false
|
|
11
11
|
private var vc: VideoTrimmerViewController?
|
|
12
|
-
private var isVideoType = true
|
|
13
12
|
private var outputFile: URL?
|
|
14
13
|
private var editorConfig: NSDictionary?
|
|
15
14
|
|
|
@@ -260,7 +259,7 @@ public class VideoTrim: RCTEventEmitter, AssetLoaderDelegate, UIDocumentPickerDe
|
|
|
260
259
|
}
|
|
261
260
|
}
|
|
262
261
|
|
|
263
|
-
private func trim(viewController: VideoTrimmerViewController, inputFile: URL, videoDuration: Double, startTime: Double, endTime: Double) {
|
|
262
|
+
private func trim(viewController: VideoTrimmerViewController, inputFile: URL, videoDuration: Double, startTime: Double, endTime: Double, isVideoType: Bool) {
|
|
264
263
|
vc?.pausePlayer()
|
|
265
264
|
|
|
266
265
|
let timestamp = Int(Date().timeIntervalSince1970)
|
|
@@ -371,7 +370,7 @@ public class VideoTrim: RCTEventEmitter, AssetLoaderDelegate, UIDocumentPickerDe
|
|
|
371
370
|
let eventPayload: [String: Any] = ["outputPath": self.outputFile!.absoluteString, "startTime": (startTime * 1000).rounded(), "endTime": (endTime * 1000).rounded(), "duration": (videoDuration * 1000).rounded()]
|
|
372
371
|
self.emitEventToJS("onFinishTrimming", eventData: eventPayload)
|
|
373
372
|
|
|
374
|
-
if (self.saveToPhoto &&
|
|
373
|
+
if (self.saveToPhoto && isVideoType) {
|
|
375
374
|
PHPhotoLibrary.requestAuthorization { status in
|
|
376
375
|
guard status == .authorized else {
|
|
377
376
|
self.onError(message: "Permission to access Photo Library is not granted", code: .noPhotoPermission)
|
|
@@ -755,9 +754,11 @@ extension VideoTrim {
|
|
|
755
754
|
}
|
|
756
755
|
}
|
|
757
756
|
|
|
757
|
+
let isVideoType = (config["type"] as? String ?? "video") == "video"
|
|
758
|
+
|
|
758
759
|
vc.saveBtnClicked = {(selectedRange: CMTimeRange) in
|
|
759
760
|
if !self.enableSaveDialog {
|
|
760
|
-
self.trim(viewController: vc,inputFile: destPath, videoDuration: self.vc!.asset!.duration.seconds, startTime: selectedRange.start.seconds, endTime: selectedRange.end.seconds)
|
|
761
|
+
self.trim(viewController: vc,inputFile: destPath, videoDuration: self.vc!.asset!.duration.seconds, startTime: selectedRange.start.seconds, endTime: selectedRange.end.seconds, isVideoType: isVideoType)
|
|
761
762
|
return
|
|
762
763
|
}
|
|
763
764
|
|
|
@@ -767,7 +768,7 @@ extension VideoTrim {
|
|
|
767
768
|
|
|
768
769
|
// Create OK button with action handler
|
|
769
770
|
let ok = UIAlertAction(title: self.saveDialogConfirmText, style: .default, handler: { (action) -> Void in
|
|
770
|
-
self.trim(viewController: vc,inputFile: destPath, videoDuration: vc.asset!.duration.seconds, startTime: selectedRange.start.seconds, endTime: selectedRange.end.seconds)
|
|
771
|
+
self.trim(viewController: vc,inputFile: destPath, videoDuration: vc.asset!.duration.seconds, startTime: selectedRange.start.seconds, endTime: selectedRange.end.seconds, isVideoType: isVideoType)
|
|
771
772
|
})
|
|
772
773
|
|
|
773
774
|
// Create Cancel button with action handlder
|
|
@@ -798,7 +799,7 @@ extension VideoTrim {
|
|
|
798
799
|
// otherwise it may run too fast for local file and autoplay looks weird
|
|
799
800
|
let assetLoader = AssetLoader()
|
|
800
801
|
assetLoader.delegate = self
|
|
801
|
-
assetLoader.loadAsset(url: destPath, isVideoType:
|
|
802
|
+
assetLoader.loadAsset(url: destPath, isVideoType: isVideoType)
|
|
802
803
|
})
|
|
803
804
|
}
|
|
804
805
|
}
|
|
@@ -332,7 +332,7 @@ class VideoTrimmerViewController: UIViewController {
|
|
|
332
332
|
trimmer.zoomOnWaitingDuration = zoomOnWaitingDuration
|
|
333
333
|
|
|
334
334
|
if let maxDuration = maximumDuration {
|
|
335
|
-
trimmer.maximumDuration = CMTime(seconds: max(1, Double(maxDuration)), preferredTimescale: 600)
|
|
335
|
+
trimmer.maximumDuration = CMTime(seconds: max(1, Double(maxDuration) / 1000.0), preferredTimescale: 600)
|
|
336
336
|
if trimmer.maximumDuration > asset!.duration {
|
|
337
337
|
trimmer.maximumDuration = asset!.duration
|
|
338
338
|
}
|
|
@@ -340,7 +340,7 @@ class VideoTrimmerViewController: UIViewController {
|
|
|
340
340
|
}
|
|
341
341
|
|
|
342
342
|
if let minDuration = minimumDuration {
|
|
343
|
-
trimmer.minimumDuration = CMTime(seconds: max(1, Double(minDuration)), preferredTimescale: 600)
|
|
343
|
+
trimmer.minimumDuration = CMTime(seconds: max(1, Double(minDuration) / 1000.0), preferredTimescale: 600)
|
|
344
344
|
}
|
|
345
345
|
|
|
346
346
|
trimmer.addTarget(self, action: #selector(didBeginScrubbing(_:)), for: VideoTrimmer.didBeginScrubbing)
|
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { TurboModuleRegistry } from 'react-native';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Base options shared by both the editor and headless trim operations.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Configuration for the video trimmer editor UI.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Options for headless (non-UI) trim operations.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Result returned by {@link Spec.isValidFile}.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Result returned by a trim operation (both editor and headless).
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* TurboModule spec for the native VideoTrim module.
|
|
27
|
+
*/
|
|
28
|
+
|
|
4
29
|
export default TurboModuleRegistry.getEnforcing('VideoTrim');
|
|
5
30
|
//# sourceMappingURL=NativeVideoTrim.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeVideoTrim.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeVideoTrim.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;;AAGlD;AACA;AACA;;AAkBA;AACA;AACA;;AAgGA;AACA;AACA;;AAQA;AACA;AACA;;AAUA;AACA;AACA;;AAcA;AACA;AACA;;AAmEA,eAAeA,mBAAmB,CAACC,YAAY,CAAO,WAAW,CAAC","ignoreList":[]}
|
|
@@ -1,115 +1,202 @@
|
|
|
1
1
|
import type { TurboModule } from 'react-native';
|
|
2
2
|
import type { EventEmitter } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
|
+
/**
|
|
4
|
+
* Base options shared by both the editor and headless trim operations.
|
|
5
|
+
*/
|
|
3
6
|
export interface BaseOptions {
|
|
7
|
+
/** Whether to save the output file to the device's photo library. */
|
|
4
8
|
saveToPhoto: boolean;
|
|
9
|
+
/** Media type: `"video"` or `"audio"`. */
|
|
5
10
|
type: string;
|
|
11
|
+
/** Output file extension (e.g. `"mp4"`, `"wav"`). */
|
|
6
12
|
outputExt: string;
|
|
13
|
+
/** Whether to remove the output file after it has been saved to the photo library. */
|
|
7
14
|
removeAfterSavedToPhoto: boolean;
|
|
15
|
+
/** Whether to remove the output file if saving to the photo library fails. */
|
|
8
16
|
removeAfterFailedToSavePhoto: boolean;
|
|
17
|
+
/** Whether to enable video rotation during trimming. */
|
|
9
18
|
enableRotation: boolean;
|
|
19
|
+
/** Rotation angle in degrees (e.g. `90`, `180`, `270`). Only used when `enableRotation` is `true`. */
|
|
10
20
|
rotationAngle: number;
|
|
11
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Configuration for the video trimmer editor UI.
|
|
24
|
+
*/
|
|
12
25
|
export interface EditorConfig extends BaseOptions {
|
|
26
|
+
/** Whether to enable haptic feedback when interacting with the trimmer. */
|
|
13
27
|
enableHapticFeedback: boolean;
|
|
28
|
+
/** Maximum allowed duration for the trimmed clip in milliseconds. Set to `-1` for no limit. */
|
|
14
29
|
maxDuration: number;
|
|
30
|
+
/** Minimum allowed duration for the trimmed clip in milliseconds. Set to `-1` for no limit. */
|
|
15
31
|
minDuration: number;
|
|
32
|
+
/** Whether to open the system documents/files app after trimming finishes. */
|
|
16
33
|
openDocumentsOnFinish: boolean;
|
|
34
|
+
/** Whether to open the share sheet after trimming finishes. */
|
|
17
35
|
openShareSheetOnFinish: boolean;
|
|
36
|
+
/** Whether to remove the output file after it has been saved to documents. */
|
|
18
37
|
removeAfterSavedToDocuments: boolean;
|
|
38
|
+
/** Whether to remove the output file if saving to documents fails. */
|
|
19
39
|
removeAfterFailedToSaveDocuments: boolean;
|
|
40
|
+
/** Whether to remove the output file after it has been shared. */
|
|
20
41
|
removeAfterShared: boolean;
|
|
42
|
+
/** Whether to remove the output file if sharing fails. */
|
|
21
43
|
removeAfterFailedToShare: boolean;
|
|
44
|
+
/** Text for the cancel button. */
|
|
22
45
|
cancelButtonText: string;
|
|
46
|
+
/** Text for the save button. */
|
|
23
47
|
saveButtonText: string;
|
|
48
|
+
/** Whether to show a confirmation dialog when the cancel button is pressed. */
|
|
24
49
|
enableCancelDialog: boolean;
|
|
50
|
+
/** Title of the cancel confirmation dialog. */
|
|
25
51
|
cancelDialogTitle: string;
|
|
52
|
+
/** Message of the cancel confirmation dialog. */
|
|
26
53
|
cancelDialogMessage: string;
|
|
54
|
+
/** Text for the dismiss button in the cancel confirmation dialog. */
|
|
27
55
|
cancelDialogCancelText: string;
|
|
56
|
+
/** Text for the confirm button in the cancel confirmation dialog. */
|
|
28
57
|
cancelDialogConfirmText: string;
|
|
58
|
+
/** Whether to show a confirmation dialog when the save button is pressed. */
|
|
29
59
|
enableSaveDialog: boolean;
|
|
60
|
+
/** Title of the save confirmation dialog. */
|
|
30
61
|
saveDialogTitle: string;
|
|
62
|
+
/** Message of the save confirmation dialog. */
|
|
31
63
|
saveDialogMessage: string;
|
|
64
|
+
/** Text for the dismiss button in the save confirmation dialog. */
|
|
32
65
|
saveDialogCancelText: string;
|
|
66
|
+
/** Text for the confirm button in the save confirmation dialog. */
|
|
33
67
|
saveDialogConfirmText: string;
|
|
68
|
+
/** Text displayed while the video is being trimmed (e.g. `"Trimming video..."`). */
|
|
34
69
|
trimmingText: string;
|
|
70
|
+
/** iOS only. Whether to present the editor as a full-screen modal. */
|
|
35
71
|
fullScreenModalIOS: boolean;
|
|
72
|
+
/** Whether to auto-play the video when the editor opens. */
|
|
36
73
|
autoplay: boolean;
|
|
74
|
+
/** Position in milliseconds to seek to when the editor loads. Set to `-1` to disable. */
|
|
37
75
|
jumpToPositionOnLoad: number;
|
|
76
|
+
/** Whether to automatically close the editor when trimming finishes. */
|
|
38
77
|
closeWhenFinish: boolean;
|
|
78
|
+
/** Whether to allow the user to cancel an in-progress trim operation. */
|
|
39
79
|
enableCancelTrimming: boolean;
|
|
80
|
+
/** Text for the cancel-trimming button. */
|
|
40
81
|
cancelTrimmingButtonText: string;
|
|
82
|
+
/** Whether to show a confirmation dialog when cancelling an in-progress trim. */
|
|
41
83
|
enableCancelTrimmingDialog: boolean;
|
|
84
|
+
/** Title of the cancel-trimming confirmation dialog. */
|
|
42
85
|
cancelTrimmingDialogTitle: string;
|
|
86
|
+
/** Message of the cancel-trimming confirmation dialog. */
|
|
43
87
|
cancelTrimmingDialogMessage: string;
|
|
88
|
+
/** Text for the dismiss button in the cancel-trimming dialog. */
|
|
44
89
|
cancelTrimmingDialogCancelText: string;
|
|
90
|
+
/** Text for the confirm button in the cancel-trimming dialog. */
|
|
45
91
|
cancelTrimmingDialogConfirmText: string;
|
|
92
|
+
/** Custom header text displayed at the top of the editor. */
|
|
46
93
|
headerText: string;
|
|
94
|
+
/** Font size of the header text in sp/pt. */
|
|
47
95
|
headerTextSize: number;
|
|
96
|
+
/** Color of the header text as a `processColor` value. */
|
|
48
97
|
headerTextColor: number;
|
|
98
|
+
/** Whether to show an alert dialog when the media file fails to load. */
|
|
49
99
|
alertOnFailToLoad: boolean;
|
|
100
|
+
/** Title of the fail-to-load alert. */
|
|
50
101
|
alertOnFailTitle: string;
|
|
102
|
+
/** Message of the fail-to-load alert. */
|
|
51
103
|
alertOnFailMessage: string;
|
|
104
|
+
/** Text for the close button of the fail-to-load alert. */
|
|
52
105
|
alertOnFailCloseText: string;
|
|
53
|
-
/**
|
|
54
|
-
* Android only
|
|
55
|
-
* Update status bar to black background color when editor is opened
|
|
56
|
-
*/
|
|
106
|
+
/** Android only. Whether to update the status bar to a black background when the editor opens. */
|
|
57
107
|
changeStatusBarColorOnOpen?: boolean;
|
|
58
|
-
/**
|
|
59
|
-
* Color of the trimmer bar
|
|
60
|
-
*/
|
|
108
|
+
/** Color of the trimmer bar as a `processColor` value. */
|
|
61
109
|
trimmerColor?: number;
|
|
62
|
-
/**
|
|
63
|
-
* Color of the trimmer left/right handle icons
|
|
64
|
-
*/
|
|
110
|
+
/** Color of the trimmer left/right handle icons as a `processColor` value. */
|
|
65
111
|
handleIconColor?: number;
|
|
66
112
|
/**
|
|
67
|
-
* Duration for zoom-on-waiting feature in milliseconds (default: 5000)
|
|
68
|
-
* When user pauses while dragging trim handles, the view
|
|
69
|
-
* this duration around the current trim position for more precise editing
|
|
113
|
+
* Duration for the zoom-on-waiting feature in milliseconds (default: `5000`).
|
|
114
|
+
* When the user pauses while dragging trim handles, the view zooms to show
|
|
115
|
+
* this duration around the current trim position for more precise editing.
|
|
70
116
|
*/
|
|
71
117
|
zoomOnWaitingDuration?: number;
|
|
72
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Options for headless (non-UI) trim operations.
|
|
121
|
+
*/
|
|
73
122
|
export interface TrimOptions extends BaseOptions {
|
|
123
|
+
/** Start time of the trim range in milliseconds. */
|
|
74
124
|
startTime: number;
|
|
125
|
+
/** End time of the trim range in milliseconds. */
|
|
75
126
|
endTime: number;
|
|
76
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Result returned by {@link Spec.isValidFile}.
|
|
130
|
+
*/
|
|
77
131
|
export interface FileValidationResult {
|
|
132
|
+
/** Whether the file is a valid audio or video file. */
|
|
78
133
|
isValid: boolean;
|
|
134
|
+
/** Detected file type (e.g. `"video"`, `"audio"`, `"unknown"`). */
|
|
79
135
|
fileType: string;
|
|
136
|
+
/** Duration of the media file in milliseconds, or `-1` if invalid. */
|
|
80
137
|
duration: number;
|
|
81
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Result returned by a trim operation (both editor and headless).
|
|
141
|
+
*/
|
|
82
142
|
export interface TrimResult {
|
|
143
|
+
/** Start time of the trimmed range in milliseconds. */
|
|
83
144
|
startTime: number;
|
|
145
|
+
/** End time of the trimmed range in milliseconds. */
|
|
84
146
|
endTime: number;
|
|
147
|
+
/** Duration of the trimmed clip in milliseconds. */
|
|
85
148
|
duration: number;
|
|
149
|
+
/** Absolute path to the trimmed output file. */
|
|
86
150
|
outputPath: string;
|
|
151
|
+
/** Whether the trim operation completed successfully. */
|
|
87
152
|
success: boolean;
|
|
88
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* TurboModule spec for the native VideoTrim module.
|
|
156
|
+
*/
|
|
89
157
|
export interface Spec extends TurboModule {
|
|
158
|
+
/** Open the video trimmer editor for the given file. */
|
|
90
159
|
showEditor(filePath: string, config: EditorConfig): void;
|
|
160
|
+
/** List all output files generated by past trim operations. */
|
|
91
161
|
listFiles(): Promise<string[]>;
|
|
162
|
+
/** Delete all output files generated by past trim operations. Returns the number of files removed. */
|
|
92
163
|
cleanFiles(): Promise<number>;
|
|
164
|
+
/** Delete a single file at the given path. Resolves `true` on success. */
|
|
93
165
|
deleteFile(filePath: string): Promise<boolean>;
|
|
166
|
+
/** Programmatically close the editor if it is currently open. */
|
|
94
167
|
closeEditor(): void;
|
|
168
|
+
/** Check whether the given URL points to a valid audio or video file. */
|
|
95
169
|
isValidFile(url: string): Promise<FileValidationResult>;
|
|
170
|
+
/** Perform a headless trim (no UI) on the given URL with the specified options. */
|
|
96
171
|
trim(url: string, options: TrimOptions): Promise<TrimResult>;
|
|
172
|
+
/** Emitted when the trim operation starts. */
|
|
97
173
|
readonly onStartTrimming: EventEmitter<void>;
|
|
174
|
+
/** Emitted when the user cancels an in-progress trim operation. */
|
|
98
175
|
readonly onCancelTrimming: EventEmitter<void>;
|
|
176
|
+
/** Emitted when the user dismisses the editor without trimming. */
|
|
99
177
|
readonly onCancel: EventEmitter<void>;
|
|
178
|
+
/** Emitted when the editor is hidden. */
|
|
100
179
|
readonly onHide: EventEmitter<void>;
|
|
180
|
+
/** Emitted when the editor is shown. */
|
|
101
181
|
readonly onShow: EventEmitter<void>;
|
|
182
|
+
/** Emitted when trimming completes successfully. All time values are in milliseconds. */
|
|
102
183
|
readonly onFinishTrimming: EventEmitter<{
|
|
184
|
+
/** Absolute path to the trimmed output file. */
|
|
103
185
|
outputPath: string;
|
|
186
|
+
/** Start time of the trimmed range in milliseconds. */
|
|
104
187
|
startTime: number;
|
|
188
|
+
/** End time of the trimmed range in milliseconds. */
|
|
105
189
|
endTime: number;
|
|
190
|
+
/** Duration of the trimmed clip in milliseconds. */
|
|
106
191
|
duration: number;
|
|
107
192
|
}>;
|
|
193
|
+
/** Emitted with FFmpeg log output during trimming. */
|
|
108
194
|
readonly onLog: EventEmitter<{
|
|
109
195
|
level: string;
|
|
110
196
|
message: string;
|
|
111
197
|
sessionId: number;
|
|
112
198
|
}>;
|
|
199
|
+
/** Emitted with FFmpeg encoding statistics during trimming. */
|
|
113
200
|
readonly onStatistics: EventEmitter<{
|
|
114
201
|
sessionId: number;
|
|
115
202
|
videoFrameNumber: number;
|
|
@@ -120,11 +207,14 @@ export interface Spec extends TurboModule {
|
|
|
120
207
|
bitrate: number;
|
|
121
208
|
speed: number;
|
|
122
209
|
}>;
|
|
210
|
+
/** Emitted when an error occurs during trimming or file loading. */
|
|
123
211
|
readonly onError: EventEmitter<{
|
|
124
212
|
message: string;
|
|
125
213
|
errorCode: string;
|
|
126
214
|
}>;
|
|
215
|
+
/** Emitted when the media file has finished loading in the editor. */
|
|
127
216
|
readonly onLoad: EventEmitter<{
|
|
217
|
+
/** Duration of the loaded media in milliseconds. */
|
|
128
218
|
duration: number;
|
|
129
219
|
}>;
|
|
130
220
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeVideoTrim.d.ts","sourceRoot":"","sources":["../../../src/NativeVideoTrim.ts"],"names":[],"mappings":"AAA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AC;QAClB,qDAAqD;QACrD,OAAO,EAAE,MAAM,CAAC;QAChB,oDAAoD;QACpD,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC,CAAC;IACH,sDAAsD;IACtD,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;QAC3B,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC,CAAC;IACH,+DAA+D;IAC/D,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;QAClC,SAAS,EAAE,MAAM,CAAC;QAClB,gBAAgB,EAAE,MAAM,CAAC;QACzB,QAAQ,EAAE,MAAM,CAAC;QACjB,YAAY,EAAE,MAAM,CAAC;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC,CAAC;IACH,oEAAoE;IACpE,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;QAC7B,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC,CAAC;IACH,sEAAsE;IACtE,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;QAC5B,oDAAoD;QACpD,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC,CAAC;CACJ;;AAED,wBAAmE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-video-trim",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"description": "Video trimmer for your React Native app",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -88,7 +88,10 @@
|
|
|
88
88
|
"react": "*",
|
|
89
89
|
"react-native": "*"
|
|
90
90
|
},
|
|
91
|
-
"
|
|
91
|
+
"workspaces": [
|
|
92
|
+
"example"
|
|
93
|
+
],
|
|
94
|
+
"packageManager": "yarn@3.6.1",
|
|
92
95
|
"jest": {
|
|
93
96
|
"preset": "react-native",
|
|
94
97
|
"modulePathIgnorePatterns": [
|
package/src/NativeVideoTrim.ts
CHANGED
|
@@ -2,122 +2,209 @@ import type { TurboModule } from 'react-native';
|
|
|
2
2
|
import { TurboModuleRegistry } from 'react-native';
|
|
3
3
|
import type { EventEmitter } from 'react-native/Libraries/Types/CodegenTypes';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Base options shared by both the editor and headless trim operations.
|
|
7
|
+
*/
|
|
5
8
|
export interface BaseOptions {
|
|
9
|
+
/** Whether to save the output file to the device's photo library. */
|
|
6
10
|
saveToPhoto: boolean;
|
|
11
|
+
/** Media type: `"video"` or `"audio"`. */
|
|
7
12
|
type: string;
|
|
13
|
+
/** Output file extension (e.g. `"mp4"`, `"wav"`). */
|
|
8
14
|
outputExt: string;
|
|
15
|
+
/** Whether to remove the output file after it has been saved to the photo library. */
|
|
9
16
|
removeAfterSavedToPhoto: boolean;
|
|
17
|
+
/** Whether to remove the output file if saving to the photo library fails. */
|
|
10
18
|
removeAfterFailedToSavePhoto: boolean;
|
|
19
|
+
/** Whether to enable video rotation during trimming. */
|
|
11
20
|
enableRotation: boolean;
|
|
21
|
+
/** Rotation angle in degrees (e.g. `90`, `180`, `270`). Only used when `enableRotation` is `true`. */
|
|
12
22
|
rotationAngle: number;
|
|
13
23
|
}
|
|
14
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Configuration for the video trimmer editor UI.
|
|
27
|
+
*/
|
|
15
28
|
export interface EditorConfig extends BaseOptions {
|
|
29
|
+
/** Whether to enable haptic feedback when interacting with the trimmer. */
|
|
16
30
|
enableHapticFeedback: boolean;
|
|
31
|
+
/** Maximum allowed duration for the trimmed clip in milliseconds. Set to `-1` for no limit. */
|
|
17
32
|
maxDuration: number;
|
|
33
|
+
/** Minimum allowed duration for the trimmed clip in milliseconds. Set to `-1` for no limit. */
|
|
18
34
|
minDuration: number;
|
|
35
|
+
/** Whether to open the system documents/files app after trimming finishes. */
|
|
19
36
|
openDocumentsOnFinish: boolean;
|
|
37
|
+
/** Whether to open the share sheet after trimming finishes. */
|
|
20
38
|
openShareSheetOnFinish: boolean;
|
|
39
|
+
/** Whether to remove the output file after it has been saved to documents. */
|
|
21
40
|
removeAfterSavedToDocuments: boolean;
|
|
41
|
+
/** Whether to remove the output file if saving to documents fails. */
|
|
22
42
|
removeAfterFailedToSaveDocuments: boolean;
|
|
43
|
+
/** Whether to remove the output file after it has been shared. */
|
|
23
44
|
removeAfterShared: boolean;
|
|
45
|
+
/** Whether to remove the output file if sharing fails. */
|
|
24
46
|
removeAfterFailedToShare: boolean;
|
|
47
|
+
/** Text for the cancel button. */
|
|
25
48
|
cancelButtonText: string;
|
|
49
|
+
/** Text for the save button. */
|
|
26
50
|
saveButtonText: string;
|
|
51
|
+
/** Whether to show a confirmation dialog when the cancel button is pressed. */
|
|
27
52
|
enableCancelDialog: boolean;
|
|
53
|
+
/** Title of the cancel confirmation dialog. */
|
|
28
54
|
cancelDialogTitle: string;
|
|
55
|
+
/** Message of the cancel confirmation dialog. */
|
|
29
56
|
cancelDialogMessage: string;
|
|
57
|
+
/** Text for the dismiss button in the cancel confirmation dialog. */
|
|
30
58
|
cancelDialogCancelText: string;
|
|
59
|
+
/** Text for the confirm button in the cancel confirmation dialog. */
|
|
31
60
|
cancelDialogConfirmText: string;
|
|
61
|
+
/** Whether to show a confirmation dialog when the save button is pressed. */
|
|
32
62
|
enableSaveDialog: boolean;
|
|
63
|
+
/** Title of the save confirmation dialog. */
|
|
33
64
|
saveDialogTitle: string;
|
|
65
|
+
/** Message of the save confirmation dialog. */
|
|
34
66
|
saveDialogMessage: string;
|
|
67
|
+
/** Text for the dismiss button in the save confirmation dialog. */
|
|
35
68
|
saveDialogCancelText: string;
|
|
69
|
+
/** Text for the confirm button in the save confirmation dialog. */
|
|
36
70
|
saveDialogConfirmText: string;
|
|
71
|
+
/** Text displayed while the video is being trimmed (e.g. `"Trimming video..."`). */
|
|
37
72
|
trimmingText: string;
|
|
73
|
+
/** iOS only. Whether to present the editor as a full-screen modal. */
|
|
38
74
|
fullScreenModalIOS: boolean;
|
|
75
|
+
/** Whether to auto-play the video when the editor opens. */
|
|
39
76
|
autoplay: boolean;
|
|
77
|
+
/** Position in milliseconds to seek to when the editor loads. Set to `-1` to disable. */
|
|
40
78
|
jumpToPositionOnLoad: number;
|
|
79
|
+
/** Whether to automatically close the editor when trimming finishes. */
|
|
41
80
|
closeWhenFinish: boolean;
|
|
81
|
+
/** Whether to allow the user to cancel an in-progress trim operation. */
|
|
42
82
|
enableCancelTrimming: boolean;
|
|
83
|
+
/** Text for the cancel-trimming button. */
|
|
43
84
|
cancelTrimmingButtonText: string;
|
|
85
|
+
/** Whether to show a confirmation dialog when cancelling an in-progress trim. */
|
|
44
86
|
enableCancelTrimmingDialog: boolean;
|
|
87
|
+
/** Title of the cancel-trimming confirmation dialog. */
|
|
45
88
|
cancelTrimmingDialogTitle: string;
|
|
89
|
+
/** Message of the cancel-trimming confirmation dialog. */
|
|
46
90
|
cancelTrimmingDialogMessage: string;
|
|
91
|
+
/** Text for the dismiss button in the cancel-trimming dialog. */
|
|
47
92
|
cancelTrimmingDialogCancelText: string;
|
|
93
|
+
/** Text for the confirm button in the cancel-trimming dialog. */
|
|
48
94
|
cancelTrimmingDialogConfirmText: string;
|
|
95
|
+
/** Custom header text displayed at the top of the editor. */
|
|
49
96
|
headerText: string;
|
|
97
|
+
/** Font size of the header text in sp/pt. */
|
|
50
98
|
headerTextSize: number;
|
|
99
|
+
/** Color of the header text as a `processColor` value. */
|
|
51
100
|
headerTextColor: number;
|
|
101
|
+
/** Whether to show an alert dialog when the media file fails to load. */
|
|
52
102
|
alertOnFailToLoad: boolean;
|
|
103
|
+
/** Title of the fail-to-load alert. */
|
|
53
104
|
alertOnFailTitle: string;
|
|
105
|
+
/** Message of the fail-to-load alert. */
|
|
54
106
|
alertOnFailMessage: string;
|
|
107
|
+
/** Text for the close button of the fail-to-load alert. */
|
|
55
108
|
alertOnFailCloseText: string;
|
|
56
|
-
/**
|
|
57
|
-
* Android only
|
|
58
|
-
* Update status bar to black background color when editor is opened
|
|
59
|
-
*/
|
|
109
|
+
/** Android only. Whether to update the status bar to a black background when the editor opens. */
|
|
60
110
|
changeStatusBarColorOnOpen?: boolean;
|
|
61
|
-
/**
|
|
62
|
-
* Color of the trimmer bar
|
|
63
|
-
*/
|
|
111
|
+
/** Color of the trimmer bar as a `processColor` value. */
|
|
64
112
|
trimmerColor?: number;
|
|
65
|
-
/**
|
|
66
|
-
* Color of the trimmer left/right handle icons
|
|
67
|
-
*/
|
|
113
|
+
/** Color of the trimmer left/right handle icons as a `processColor` value. */
|
|
68
114
|
handleIconColor?: number;
|
|
69
115
|
/**
|
|
70
|
-
* Duration for zoom-on-waiting feature in milliseconds (default: 5000)
|
|
71
|
-
* When user pauses while dragging trim handles, the view
|
|
72
|
-
* this duration around the current trim position for more precise editing
|
|
116
|
+
* Duration for the zoom-on-waiting feature in milliseconds (default: `5000`).
|
|
117
|
+
* When the user pauses while dragging trim handles, the view zooms to show
|
|
118
|
+
* this duration around the current trim position for more precise editing.
|
|
73
119
|
*/
|
|
74
120
|
zoomOnWaitingDuration?: number;
|
|
75
121
|
}
|
|
76
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Options for headless (non-UI) trim operations.
|
|
125
|
+
*/
|
|
77
126
|
export interface TrimOptions extends BaseOptions {
|
|
127
|
+
/** Start time of the trim range in milliseconds. */
|
|
78
128
|
startTime: number;
|
|
129
|
+
/** End time of the trim range in milliseconds. */
|
|
79
130
|
endTime: number;
|
|
80
131
|
}
|
|
81
132
|
|
|
133
|
+
/**
|
|
134
|
+
* Result returned by {@link Spec.isValidFile}.
|
|
135
|
+
*/
|
|
82
136
|
export interface FileValidationResult {
|
|
137
|
+
/** Whether the file is a valid audio or video file. */
|
|
83
138
|
isValid: boolean;
|
|
139
|
+
/** Detected file type (e.g. `"video"`, `"audio"`, `"unknown"`). */
|
|
84
140
|
fileType: string;
|
|
141
|
+
/** Duration of the media file in milliseconds, or `-1` if invalid. */
|
|
85
142
|
duration: number;
|
|
86
143
|
}
|
|
87
144
|
|
|
145
|
+
/**
|
|
146
|
+
* Result returned by a trim operation (both editor and headless).
|
|
147
|
+
*/
|
|
88
148
|
export interface TrimResult {
|
|
149
|
+
/** Start time of the trimmed range in milliseconds. */
|
|
89
150
|
startTime: number;
|
|
151
|
+
/** End time of the trimmed range in milliseconds. */
|
|
90
152
|
endTime: number;
|
|
153
|
+
/** Duration of the trimmed clip in milliseconds. */
|
|
91
154
|
duration: number;
|
|
155
|
+
/** Absolute path to the trimmed output file. */
|
|
92
156
|
outputPath: string;
|
|
157
|
+
/** Whether the trim operation completed successfully. */
|
|
93
158
|
success: boolean;
|
|
94
159
|
}
|
|
95
160
|
|
|
161
|
+
/**
|
|
162
|
+
* TurboModule spec for the native VideoTrim module.
|
|
163
|
+
*/
|
|
96
164
|
export interface Spec extends TurboModule {
|
|
165
|
+
/** Open the video trimmer editor for the given file. */
|
|
97
166
|
showEditor(filePath: string, config: EditorConfig): void;
|
|
167
|
+
/** List all output files generated by past trim operations. */
|
|
98
168
|
listFiles(): Promise<string[]>;
|
|
169
|
+
/** Delete all output files generated by past trim operations. Returns the number of files removed. */
|
|
99
170
|
cleanFiles(): Promise<number>;
|
|
171
|
+
/** Delete a single file at the given path. Resolves `true` on success. */
|
|
100
172
|
deleteFile(filePath: string): Promise<boolean>;
|
|
173
|
+
/** Programmatically close the editor if it is currently open. */
|
|
101
174
|
closeEditor(): void;
|
|
175
|
+
/** Check whether the given URL points to a valid audio or video file. */
|
|
102
176
|
isValidFile(url: string): Promise<FileValidationResult>;
|
|
177
|
+
/** Perform a headless trim (no UI) on the given URL with the specified options. */
|
|
103
178
|
trim(url: string, options: TrimOptions): Promise<TrimResult>;
|
|
104
179
|
|
|
180
|
+
/** Emitted when the trim operation starts. */
|
|
105
181
|
readonly onStartTrimming: EventEmitter<void>;
|
|
182
|
+
/** Emitted when the user cancels an in-progress trim operation. */
|
|
106
183
|
readonly onCancelTrimming: EventEmitter<void>;
|
|
184
|
+
/** Emitted when the user dismisses the editor without trimming. */
|
|
107
185
|
readonly onCancel: EventEmitter<void>;
|
|
186
|
+
/** Emitted when the editor is hidden. */
|
|
108
187
|
readonly onHide: EventEmitter<void>;
|
|
188
|
+
/** Emitted when the editor is shown. */
|
|
109
189
|
readonly onShow: EventEmitter<void>;
|
|
190
|
+
/** Emitted when trimming completes successfully. All time values are in milliseconds. */
|
|
110
191
|
readonly onFinishTrimming: EventEmitter<{
|
|
192
|
+
/** Absolute path to the trimmed output file. */
|
|
111
193
|
outputPath: string;
|
|
194
|
+
/** Start time of the trimmed range in milliseconds. */
|
|
112
195
|
startTime: number;
|
|
196
|
+
/** End time of the trimmed range in milliseconds. */
|
|
113
197
|
endTime: number;
|
|
198
|
+
/** Duration of the trimmed clip in milliseconds. */
|
|
114
199
|
duration: number;
|
|
115
200
|
}>;
|
|
201
|
+
/** Emitted with FFmpeg log output during trimming. */
|
|
116
202
|
readonly onLog: EventEmitter<{
|
|
117
203
|
level: string;
|
|
118
204
|
message: string;
|
|
119
205
|
sessionId: number;
|
|
120
206
|
}>;
|
|
207
|
+
/** Emitted with FFmpeg encoding statistics during trimming. */
|
|
121
208
|
readonly onStatistics: EventEmitter<{
|
|
122
209
|
sessionId: number;
|
|
123
210
|
videoFrameNumber: number;
|
|
@@ -128,11 +215,14 @@ export interface Spec extends TurboModule {
|
|
|
128
215
|
bitrate: number;
|
|
129
216
|
speed: number;
|
|
130
217
|
}>;
|
|
218
|
+
/** Emitted when an error occurs during trimming or file loading. */
|
|
131
219
|
readonly onError: EventEmitter<{
|
|
132
220
|
message: string;
|
|
133
221
|
errorCode: string;
|
|
134
222
|
}>;
|
|
223
|
+
/** Emitted when the media file has finished loading in the editor. */
|
|
135
224
|
readonly onLoad: EventEmitter<{
|
|
225
|
+
/** Duration of the loaded media in milliseconds. */
|
|
136
226
|
duration: number;
|
|
137
227
|
}>;
|
|
138
228
|
}
|