react-native-video-trim 7.1.1 → 8.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/README.md +256 -1
- package/android/src/main/java/com/videotrim/BaseVideoTrimModule.kt +488 -34
- package/android/src/main/java/com/videotrim/utils/StorageUtil.kt +95 -36
- package/android/src/main/java/com/videotrim/utils/VideoTrimmerUtil.kt +38 -16
- package/android/src/main/java/com/videotrim/widgets/VideoTrimmerView.kt +77 -0
- package/android/src/main/res/drawable/speaker_slash_fill.xml +19 -0
- package/android/src/main/res/drawable/speaker_wave_2_fill.xml +23 -0
- package/android/src/main/res/layout/video_trimmer_view.xml +22 -0
- package/android/src/newarch/VideoTrimModule.kt +33 -0
- package/android/src/oldarch/VideoTrimModule.kt +41 -0
- package/android/src/oldarch/VideoTrimSpec.kt +17 -0
- package/ios/VideoTrim.mm +155 -1
- package/ios/VideoTrim.swift +632 -39
- package/ios/VideoTrimmerViewController.swift +96 -3
- package/lib/module/NativeVideoTrim.js +52 -0
- package/lib/module/NativeVideoTrim.js.map +1 -1
- package/lib/module/index.js +142 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NativeVideoTrim.d.ts +148 -0
- package/lib/typescript/src/NativeVideoTrim.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +62 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/NativeVideoTrim.ts +161 -0
- package/src/index.tsx +183 -0
|
@@ -59,6 +59,8 @@ class VideoTrimmerViewController: UIViewController {
|
|
|
59
59
|
private var waveformBarCornerRadius: CGFloat = 1.5
|
|
60
60
|
private var iconColor: UIColor { isLightTheme ? .black : .white }
|
|
61
61
|
private var dimmedIconColor: UIColor { iconColor.withAlphaComponent(0.5) }
|
|
62
|
+
private let symbolConfig = UIImage.SymbolConfiguration(pointSize: 14, weight: .medium)
|
|
63
|
+
private let speedOptions: [Double] = [0.25, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0]
|
|
62
64
|
|
|
63
65
|
private let playerController = AVPlayerViewController()
|
|
64
66
|
private var trimmer: VideoTrimmer!
|
|
@@ -86,6 +88,10 @@ class VideoTrimmerViewController: UIViewController {
|
|
|
86
88
|
|
|
87
89
|
private(set) var rotationCount = 0
|
|
88
90
|
private(set) var isFlipped = false
|
|
91
|
+
private(set) var isMuted = false
|
|
92
|
+
private var muteBtn: UIButton?
|
|
93
|
+
private(set) var speed: Double = 1.0
|
|
94
|
+
private var speedBtn: UIButton?
|
|
89
95
|
private var isVideoType = true
|
|
90
96
|
private var playerContainerView: UIView!
|
|
91
97
|
private var transformStackView: UIStackView?
|
|
@@ -270,6 +276,7 @@ class VideoTrimmerViewController: UIViewController {
|
|
|
270
276
|
}
|
|
271
277
|
|
|
272
278
|
player.play()
|
|
279
|
+
player.rate = Float(speed)
|
|
273
280
|
}
|
|
274
281
|
|
|
275
282
|
setPlayBtnIcon()
|
|
@@ -463,6 +470,7 @@ class VideoTrimmerViewController: UIViewController {
|
|
|
463
470
|
}
|
|
464
471
|
playerController.player = AVPlayer()
|
|
465
472
|
player.replaceCurrentItem(with: AVPlayerItem(asset: asset))
|
|
473
|
+
player.isMuted = isMuted
|
|
466
474
|
|
|
467
475
|
statusObservation = player.observe(\.status, options: [.new, .initial]) { [weak self] player, _ in
|
|
468
476
|
DispatchQueue.main.async {
|
|
@@ -521,8 +529,6 @@ class VideoTrimmerViewController: UIViewController {
|
|
|
521
529
|
private func setupTransformButtons() {
|
|
522
530
|
guard isVideoType else { return }
|
|
523
531
|
|
|
524
|
-
let symbolConfig = UIImage.SymbolConfiguration(pointSize: 14, weight: .medium)
|
|
525
|
-
|
|
526
532
|
let flipBtn = UIButton(type: .system)
|
|
527
533
|
flipBtn.setImage(UIImage(systemName: "arrow.trianglehead.left.and.right.righttriangle.left.righttriangle.right", withConfiguration: symbolConfig), for: .normal)
|
|
528
534
|
flipBtn.tintColor = iconColor
|
|
@@ -539,6 +545,25 @@ class VideoTrimmerViewController: UIViewController {
|
|
|
539
545
|
cropButton.addTarget(self, action: #selector(onCropTapped), for: .touchUpInside)
|
|
540
546
|
self.cropBtn = cropButton
|
|
541
547
|
|
|
548
|
+
let muteButton = UIButton(type: .system)
|
|
549
|
+
muteButton.setImage(UIImage(systemName: isMuted ? "speaker.slash.fill" : "speaker.wave.2.fill", withConfiguration: symbolConfig), for: .normal)
|
|
550
|
+
muteButton.tintColor = iconColor
|
|
551
|
+
muteButton.addTarget(self, action: #selector(onMuteTapped), for: .touchUpInside)
|
|
552
|
+
self.muteBtn = muteButton
|
|
553
|
+
|
|
554
|
+
let speedButton = UIButton(type: .system)
|
|
555
|
+
let speedLabel = speed == 1.0 ? "1x" : "\(speed)x"
|
|
556
|
+
speedButton.setTitle(speedLabel, for: .normal)
|
|
557
|
+
speedButton.titleLabel?.font = .systemFont(ofSize: 13, weight: .semibold)
|
|
558
|
+
speedButton.tintColor = iconColor
|
|
559
|
+
if #available(iOS 14.0, *) {
|
|
560
|
+
speedButton.showsMenuAsPrimaryAction = true
|
|
561
|
+
speedButton.menu = buildSpeedMenu()
|
|
562
|
+
} else {
|
|
563
|
+
speedButton.addTarget(self, action: #selector(onSpeedTapped), for: .touchUpInside)
|
|
564
|
+
}
|
|
565
|
+
self.speedBtn = speedButton
|
|
566
|
+
|
|
542
567
|
let undoButton = UIButton(type: .system)
|
|
543
568
|
undoButton.setImage(UIImage(systemName: "arrow.uturn.backward", withConfiguration: symbolConfig), for: .normal)
|
|
544
569
|
undoButton.tintColor = dimmedIconColor
|
|
@@ -553,7 +578,7 @@ class VideoTrimmerViewController: UIViewController {
|
|
|
553
578
|
redoButton.addTarget(self, action: #selector(onRedoTapped), for: .touchUpInside)
|
|
554
579
|
self.redoBtn = redoButton
|
|
555
580
|
|
|
556
|
-
let leftStack = UIStackView(arrangedSubviews: [flipBtn, rotateBtn, cropButton])
|
|
581
|
+
let leftStack = UIStackView(arrangedSubviews: [flipBtn, rotateBtn, cropButton, muteButton, speedButton])
|
|
557
582
|
leftStack.axis = .horizontal
|
|
558
583
|
leftStack.spacing = 12
|
|
559
584
|
|
|
@@ -578,6 +603,10 @@ class VideoTrimmerViewController: UIViewController {
|
|
|
578
603
|
rotateBtn.heightAnchor.constraint(equalToConstant: btnSize),
|
|
579
604
|
cropButton.widthAnchor.constraint(equalToConstant: btnSize),
|
|
580
605
|
cropButton.heightAnchor.constraint(equalToConstant: btnSize),
|
|
606
|
+
muteButton.widthAnchor.constraint(equalToConstant: btnSize),
|
|
607
|
+
muteButton.heightAnchor.constraint(equalToConstant: btnSize),
|
|
608
|
+
speedButton.widthAnchor.constraint(greaterThanOrEqualToConstant: 36),
|
|
609
|
+
speedButton.heightAnchor.constraint(equalToConstant: btnSize),
|
|
581
610
|
undoButton.widthAnchor.constraint(equalToConstant: btnSize),
|
|
582
611
|
undoButton.heightAnchor.constraint(equalToConstant: btnSize),
|
|
583
612
|
redoButton.widthAnchor.constraint(equalToConstant: btnSize),
|
|
@@ -590,6 +619,66 @@ class VideoTrimmerViewController: UIViewController {
|
|
|
590
619
|
self.transformStackView = fullRow
|
|
591
620
|
}
|
|
592
621
|
|
|
622
|
+
@objc private func onMuteTapped() {
|
|
623
|
+
isMuted.toggle()
|
|
624
|
+
muteBtn?.setImage(UIImage(systemName: isMuted ? "speaker.slash.fill" : "speaker.wave.2.fill", withConfiguration: symbolConfig), for: .normal)
|
|
625
|
+
player.isMuted = isMuted
|
|
626
|
+
if enableHapticFeedback {
|
|
627
|
+
UIImpactFeedbackGenerator(style: .light).impactOccurred()
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
// Builds a native context menu for speed selection (iOS 14+). The menu is
|
|
632
|
+
// attached via showsMenuAsPrimaryAction so it opens on tap without an extra
|
|
633
|
+
// long-press gesture. Falls back to UIAlertController on older iOS versions.
|
|
634
|
+
@available(iOS 14.0, *)
|
|
635
|
+
private func buildSpeedMenu() -> UIMenu {
|
|
636
|
+
let actions = speedOptions.map { opt in
|
|
637
|
+
let title = opt == 1.0 ? "Normal (1x)" : "\(opt)x"
|
|
638
|
+
let isSelected = abs(opt - speed) < 0.0001
|
|
639
|
+
return UIAction(title: title, state: isSelected ? .on : .off) { [weak self] _ in
|
|
640
|
+
self?.setSpeed(opt)
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
return UIMenu(title: "", children: actions)
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
/// Fallback for iOS < 14 where UIMenu is unavailable.
|
|
647
|
+
@objc private func onSpeedTapped() {
|
|
648
|
+
let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
|
649
|
+
alert.overrideUserInterfaceStyle = isLightTheme ? .light : .dark
|
|
650
|
+
for opt in speedOptions {
|
|
651
|
+
let title = opt == 1.0 ? "Normal (1x)" : "\(opt)x"
|
|
652
|
+
let isSelected = abs(opt - speed) < 0.0001
|
|
653
|
+
let action = UIAlertAction(title: title, style: isSelected ? .destructive : .default) { [weak self] _ in
|
|
654
|
+
self?.setSpeed(opt)
|
|
655
|
+
}
|
|
656
|
+
alert.addAction(action)
|
|
657
|
+
}
|
|
658
|
+
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel))
|
|
659
|
+
if let pop = alert.popoverPresentationController, let btn = speedBtn {
|
|
660
|
+
pop.sourceView = btn
|
|
661
|
+
pop.sourceRect = btn.bounds
|
|
662
|
+
}
|
|
663
|
+
present(alert, animated: true)
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
private func setSpeed(_ newSpeed: Double) {
|
|
667
|
+
speed = newSpeed
|
|
668
|
+
let label = newSpeed == 1.0 ? "1x" : "\(newSpeed)x"
|
|
669
|
+
speedBtn?.setTitle(label, for: .normal)
|
|
670
|
+
if #available(iOS 14.0, *) {
|
|
671
|
+
speedBtn?.menu = buildSpeedMenu()
|
|
672
|
+
}
|
|
673
|
+
player.rate = Float(newSpeed)
|
|
674
|
+
if player.timeControlStatus != .playing {
|
|
675
|
+
player.pause()
|
|
676
|
+
}
|
|
677
|
+
if enableHapticFeedback {
|
|
678
|
+
UIImpactFeedbackGenerator(style: .light).impactOccurred()
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
|
|
593
682
|
@objc private func onFlipTapped() {
|
|
594
683
|
pushUndo()
|
|
595
684
|
isFlipped.toggle()
|
|
@@ -978,6 +1067,10 @@ class VideoTrimmerViewController: UIViewController {
|
|
|
978
1067
|
zoomOnWaitingDuration = (config["zoomOnWaitingDuration"] as? Double ?? 5.0) / 1000.0 // convert ms to s
|
|
979
1068
|
autoplay = config["autoplay"] as? Bool ?? false
|
|
980
1069
|
isVideoType = (config["type"] as? String ?? "video") == "video"
|
|
1070
|
+
isMuted = config["removeAudio"] as? Bool ?? false
|
|
1071
|
+
if let cfgSpeed = config["speed"] as? Double {
|
|
1072
|
+
speed = cfgSpeed
|
|
1073
|
+
}
|
|
981
1074
|
headerText = config["headerText"] as? String
|
|
982
1075
|
headerTextSize = config["headerTextSize"] as? Int ?? 16
|
|
983
1076
|
headerTextColor = config["headerTextColor"] as? Double
|
|
@@ -22,6 +22,58 @@ import { TurboModuleRegistry } from 'react-native';
|
|
|
22
22
|
* Result returned by a trim operation (both editor and headless).
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Options for extracting a single frame from a video.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Result returned by {@link Spec.getFrameAt}.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Options for extracting the audio track from a video file.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Result returned by {@link Spec.extractAudio}.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Options for compressing a video file.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Result returned by {@link Spec.compress}.
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Options for converting a video segment to an animated GIF.
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Result returned by {@link Spec.toGif}.
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Options for merging multiple media files into one.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Result returned by {@link Spec.merge}.
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Result returned by {@link Spec.saveToPhoto}.
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Result returned by {@link Spec.saveToDocuments}.
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Result returned by {@link Spec.share}.
|
|
75
|
+
*/
|
|
76
|
+
|
|
25
77
|
/**
|
|
26
78
|
* TurboModule spec for the native VideoTrim module.
|
|
27
79
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeVideoTrim.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;;AAGlD;AACA;AACA;;
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeVideoTrim.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;;AAGlD;AACA;AACA;;AAgCA;AACA;AACA;;AA+GA;AACA;AACA;;AAQA;AACA;AACA;;AAUA;AACA;AACA;;AAcA;AACA;AACA;;AAcA;AACA;AACA;;AAMA;AACA;AACA;;AAMA;AACA;AACA;;AAQA;AACA;AACA;;AAqBA;AACA;AACA;;AAMA;AACA;AACA;;AAYA;AACA;AACA;;AAMA;AACA;AACA;;AAMA;AACA;AACA;;AAQA;AACA;AACA;;AAMA;AACA;AACA;;AAMA;AACA;AACA;;AAMA;AACA;AACA;;AAmFA,eAAeA,mBAAmB,CAACC,YAAY,CAAO,WAAW,CAAC","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -15,6 +15,51 @@ function createBaseOptions(overrides = {}) {
|
|
|
15
15
|
removeAfterSavedToPhoto: false,
|
|
16
16
|
removeAfterFailedToSavePhoto: false,
|
|
17
17
|
enablePreciseTrimming: false,
|
|
18
|
+
removeAudio: false,
|
|
19
|
+
speed: 1.0,
|
|
20
|
+
...overrides
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function createCompressOptions(overrides = {}) {
|
|
24
|
+
return {
|
|
25
|
+
quality: 'medium',
|
|
26
|
+
bitrate: -1,
|
|
27
|
+
width: -1,
|
|
28
|
+
height: -1,
|
|
29
|
+
frameRate: -1,
|
|
30
|
+
outputExt: 'mp4',
|
|
31
|
+
removeAudio: false,
|
|
32
|
+
...overrides
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function createFrameExtractionOptions(overrides = {}) {
|
|
36
|
+
return {
|
|
37
|
+
time: 0,
|
|
38
|
+
format: 'jpeg',
|
|
39
|
+
quality: 80,
|
|
40
|
+
maxWidth: -1,
|
|
41
|
+
maxHeight: -1,
|
|
42
|
+
...overrides
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function createExtractAudioOptions(overrides = {}) {
|
|
46
|
+
return {
|
|
47
|
+
outputExt: 'm4a',
|
|
48
|
+
...overrides
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function createGifOptions(overrides = {}) {
|
|
52
|
+
return {
|
|
53
|
+
startTime: 0,
|
|
54
|
+
endTime: -1,
|
|
55
|
+
fps: 10,
|
|
56
|
+
width: -1,
|
|
57
|
+
...overrides
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function createMergeOptions(overrides = {}) {
|
|
61
|
+
return {
|
|
62
|
+
outputExt: 'mp4',
|
|
18
63
|
...overrides
|
|
19
64
|
};
|
|
20
65
|
}
|
|
@@ -171,6 +216,103 @@ export function isValidFile(url) {
|
|
|
171
216
|
export function trim(url, options) {
|
|
172
217
|
return VideoTrim.trim(url, createTrimOptions(options));
|
|
173
218
|
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Extract a single frame from a video at a given timestamp
|
|
222
|
+
*
|
|
223
|
+
* @param {string} url: absolute non-empty file path
|
|
224
|
+
* @param {Partial<FrameExtractionOptions>} options: extraction options
|
|
225
|
+
* @returns {Promise<FrameResult>} A **Promise** which resolves to the FrameResult
|
|
226
|
+
*/
|
|
227
|
+
export function getFrameAt(url, options = {}) {
|
|
228
|
+
return VideoTrim.getFrameAt(url, createFrameExtractionOptions(options));
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Extract the audio track from a video file
|
|
233
|
+
*
|
|
234
|
+
* @param {string} url: absolute non-empty file path
|
|
235
|
+
* @param {Partial<ExtractAudioOptions>} options: extraction options
|
|
236
|
+
* @returns {Promise<ExtractAudioResult>} A **Promise** which resolves to the result
|
|
237
|
+
*/
|
|
238
|
+
export function extractAudio(url, options = {}) {
|
|
239
|
+
return VideoTrim.extractAudio(url, createExtractAudioOptions(options));
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Compress a video file to reduce its size
|
|
244
|
+
*
|
|
245
|
+
* @param {string} url: absolute non-empty file path
|
|
246
|
+
* @param {Partial<CompressOptions>} options: compression options
|
|
247
|
+
* @returns {Promise<CompressResult>} A **Promise** which resolves to the result
|
|
248
|
+
*/
|
|
249
|
+
export function compress(url, options = {}) {
|
|
250
|
+
return VideoTrim.compress(url, createCompressOptions(options));
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Convert a video segment to an animated GIF
|
|
255
|
+
*
|
|
256
|
+
* @param {string} url: absolute non-empty file path
|
|
257
|
+
* @param {Partial<GifOptions>} options: GIF conversion options
|
|
258
|
+
* @returns {Promise<GifResult>} A **Promise** which resolves to the result
|
|
259
|
+
*/
|
|
260
|
+
export function toGif(url, options = {}) {
|
|
261
|
+
return VideoTrim.toGif(url, createGifOptions(options));
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Merge multiple media files into a single file (headless, no UI)
|
|
266
|
+
*
|
|
267
|
+
* @param {string[]} urls: array of file paths to merge in order
|
|
268
|
+
* @param {Partial<MergeOptions>} options: merge options
|
|
269
|
+
* @returns {Promise<MergeResult>} A **Promise** which resolves to the result
|
|
270
|
+
*/
|
|
271
|
+
export function merge(urls, options = {}) {
|
|
272
|
+
if (!urls?.length) {
|
|
273
|
+
throw new Error('URLs array cannot be empty!');
|
|
274
|
+
}
|
|
275
|
+
return VideoTrim.merge(urls, createMergeOptions(options));
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Save a file to the device's photo library
|
|
280
|
+
*
|
|
281
|
+
* @param {string} filePath: absolute path to the file
|
|
282
|
+
* @returns {Promise<SaveToPhotoResult>} A **Promise** which resolves to the result
|
|
283
|
+
*/
|
|
284
|
+
export function saveToPhoto(filePath) {
|
|
285
|
+
if (!filePath?.trim().length) {
|
|
286
|
+
throw new Error('File path cannot be empty!');
|
|
287
|
+
}
|
|
288
|
+
return VideoTrim.saveToPhoto(filePath);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Present the system document picker to save a file
|
|
293
|
+
*
|
|
294
|
+
* @param {string} filePath: absolute path to the file
|
|
295
|
+
* @returns {Promise<SaveToDocumentsResult>} A **Promise** which resolves to the result
|
|
296
|
+
*/
|
|
297
|
+
export function saveToDocuments(filePath) {
|
|
298
|
+
if (!filePath?.trim().length) {
|
|
299
|
+
throw new Error('File path cannot be empty!');
|
|
300
|
+
}
|
|
301
|
+
return VideoTrim.saveToDocuments(filePath);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Open the system share sheet for a file
|
|
306
|
+
*
|
|
307
|
+
* @param {string} filePath: absolute path to the file
|
|
308
|
+
* @returns {Promise<ShareResult>} A **Promise** which resolves to the result
|
|
309
|
+
*/
|
|
310
|
+
export function share(filePath) {
|
|
311
|
+
if (!filePath?.trim().length) {
|
|
312
|
+
throw new Error('File path cannot be empty!');
|
|
313
|
+
}
|
|
314
|
+
return VideoTrim.share(filePath);
|
|
315
|
+
}
|
|
174
316
|
export * from "./NativeVideoTrim.js";
|
|
175
317
|
export default VideoTrim;
|
|
176
318
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["VideoTrimNewArch","VideoTrimOldArch","processColor","isFabric","global","nativeFabricUIManager","VideoTrim","createBaseOptions","overrides","saveToPhoto","type","outputExt","removeAfterSavedToPhoto","removeAfterFailedToSavePhoto","enablePreciseTrimming","createEditorConfig","enableHapticFeedback","maxDuration","minDuration","openDocumentsOnFinish","openShareSheetOnFinish","removeAfterSavedToDocuments","removeAfterFailedToSaveDocuments","removeAfterShared","removeAfterFailedToShare","cancelButtonText","saveButtonText","enableCancelDialog","cancelDialogTitle","cancelDialogMessage","cancelDialogCancelText","cancelDialogConfirmText","enableSaveDialog","saveDialogTitle","saveDialogMessage","saveDialogCancelText","saveDialogConfirmText","trimmingText","fullScreenModalIOS","autoplay","jumpToPositionOnLoad","closeWhenFinish","enableCancelTrimming","cancelTrimmingButtonText","enableCancelTrimmingDialog","cancelTrimmingDialogTitle","cancelTrimmingDialogMessage","cancelTrimmingDialogCancelText","cancelTrimmingDialogConfirmText","headerText","headerTextSize","headerTextColor","trimmerColor","handleIconColor","zoomOnWaitingDuration","alertOnFailToLoad","alertOnFailTitle","alertOnFailMessage","alertOnFailCloseText","waveformColor","waveformBackgroundColor","waveformBarWidth","waveformBarGap","waveformBarCornerRadius","createTrimOptions","
|
|
1
|
+
{"version":3,"names":["VideoTrimNewArch","VideoTrimOldArch","processColor","isFabric","global","nativeFabricUIManager","VideoTrim","createBaseOptions","overrides","saveToPhoto","type","outputExt","removeAfterSavedToPhoto","removeAfterFailedToSavePhoto","enablePreciseTrimming","removeAudio","speed","createCompressOptions","quality","bitrate","width","height","frameRate","createFrameExtractionOptions","time","format","maxWidth","maxHeight","createExtractAudioOptions","createGifOptions","startTime","endTime","fps","createMergeOptions","createEditorConfig","enableHapticFeedback","maxDuration","minDuration","openDocumentsOnFinish","openShareSheetOnFinish","removeAfterSavedToDocuments","removeAfterFailedToSaveDocuments","removeAfterShared","removeAfterFailedToShare","cancelButtonText","saveButtonText","enableCancelDialog","cancelDialogTitle","cancelDialogMessage","cancelDialogCancelText","cancelDialogConfirmText","enableSaveDialog","saveDialogTitle","saveDialogMessage","saveDialogCancelText","saveDialogConfirmText","trimmingText","fullScreenModalIOS","autoplay","jumpToPositionOnLoad","closeWhenFinish","enableCancelTrimming","cancelTrimmingButtonText","enableCancelTrimmingDialog","cancelTrimmingDialogTitle","cancelTrimmingDialogMessage","cancelTrimmingDialogCancelText","cancelTrimmingDialogConfirmText","headerText","headerTextSize","headerTextColor","trimmerColor","handleIconColor","zoomOnWaitingDuration","alertOnFailToLoad","alertOnFailTitle","alertOnFailMessage","alertOnFailCloseText","waveformColor","waveformBackgroundColor","waveformBarWidth","waveformBarGap","waveformBarCornerRadius","createTrimOptions","showEditor","filePath","config","isLight","theme","_headerTextColor","_trimmerColor","_handleIconColor","_waveformColor","_waveformBackgroundColor","listFiles","cleanFiles","deleteFile","trim","length","Error","closeEditor","isValidFile","url","options","getFrameAt","extractAudio","compress","toGif","merge","urls","saveToDocuments","share"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,OAAOA,gBAAgB,MAAM,sBAAmB;AAChD,OAAOC,gBAAgB,MAAM,cAAW;AAqBxC,SAASC,YAAY,QAAQ,cAAc;;AAE3C;AACA,MAAMC,QAAQ,GAAG,CAAC,CAAEC,MAAM,CAASC,qBAAqB;AACxD,MAAMC,SAAS,GAAGH,QAAQ,GAAGH,gBAAgB,GAAGC,g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,EAAEY,IAAI,CAAC,CAAC,CAACC,MAAM,EAAE;IAC5B,MAAM,IAAIC,KAAK,CAAC,4BAA4B,CAAC;EAC/C;EACA,OAAO7F,SAAS,CAACG,WAAW,CAAC4E,QAAQ,CAAC;AACxC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASyB,eAAeA,CAACzB,QAAgB,EAAkC;EAChF,IAAI,CAACA,QAAQ,EAAEY,IAAI,CAAC,CAAC,CAACC,MAAM,EAAE;IAC5B,MAAM,IAAIC,KAAK,CAAC,4BAA4B,CAAC;EAC/C;EACA,OAAO7F,SAAS,CAACwG,eAAe,CAACzB,QAAQ,CAAC;AAC5C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS0B,KAAKA,CAAC1B,QAAgB,EAAwB;EAC5D,IAAI,CAACA,QAAQ,EAAEY,IAAI,CAAC,CAAC,CAACC,MAAM,EAAE;IAC5B,MAAM,IAAIC,KAAK,CAAC,4BAA4B,CAAC;EAC/C;EACA,OAAO7F,SAAS,CAACyG,KAAK,CAAC1B,QAAQ,CAAC;AAClC;AAEA,cAAc,sBAAmB;AACjC,eAAe/E,SAAS","ignoreList":[]}
|
|
@@ -24,6 +24,14 @@ export interface BaseOptions {
|
|
|
24
24
|
* happens regardless of this flag, so precise trimming comes for free in that case.
|
|
25
25
|
*/
|
|
26
26
|
enablePreciseTrimming: boolean;
|
|
27
|
+
/** When `true`, strips the audio track from the output. Default `false`. */
|
|
28
|
+
removeAudio: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Playback speed multiplier applied during export. `1.0` is normal speed,
|
|
31
|
+
* `2.0` is double speed, `0.5` is half speed. Valid range: 0.25–4.0.
|
|
32
|
+
* When not `1.0`, re-encoding is forced regardless of `enablePreciseTrimming`.
|
|
33
|
+
*/
|
|
34
|
+
speed: number;
|
|
27
35
|
}
|
|
28
36
|
/**
|
|
29
37
|
* Configuration for the video trimmer editor UI.
|
|
@@ -172,6 +180,130 @@ export interface TrimResult {
|
|
|
172
180
|
/** Whether the trim operation completed successfully. */
|
|
173
181
|
success: boolean;
|
|
174
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Options for extracting a single frame from a video.
|
|
185
|
+
*/
|
|
186
|
+
export interface FrameExtractionOptions {
|
|
187
|
+
/** Timestamp in milliseconds at which to extract the frame. */
|
|
188
|
+
time: number;
|
|
189
|
+
/** Output image format: `"jpeg"` (default) or `"png"`. */
|
|
190
|
+
format: string;
|
|
191
|
+
/** JPEG compression quality from 0–100. Default `80`. Ignored for PNG. */
|
|
192
|
+
quality: number;
|
|
193
|
+
/** Maximum width in pixels. Height is auto-calculated to preserve aspect ratio. `-1` for original. */
|
|
194
|
+
maxWidth: number;
|
|
195
|
+
/** Maximum height in pixels. Width is auto-calculated to preserve aspect ratio. `-1` for original. */
|
|
196
|
+
maxHeight: number;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Result returned by {@link Spec.getFrameAt}.
|
|
200
|
+
*/
|
|
201
|
+
export interface FrameResult {
|
|
202
|
+
/** Absolute path to the extracted image file. */
|
|
203
|
+
outputPath: string;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Options for extracting the audio track from a video file.
|
|
207
|
+
*/
|
|
208
|
+
export interface ExtractAudioOptions {
|
|
209
|
+
/** Output audio file extension (e.g. `"mp3"`, `"m4a"`, `"wav"`). Default `"mp3"`. */
|
|
210
|
+
outputExt: string;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Result returned by {@link Spec.extractAudio}.
|
|
214
|
+
*/
|
|
215
|
+
export interface ExtractAudioResult {
|
|
216
|
+
/** Absolute path to the extracted audio file. */
|
|
217
|
+
outputPath: string;
|
|
218
|
+
/** Duration of the audio in milliseconds. */
|
|
219
|
+
duration: number;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Options for compressing a video file.
|
|
223
|
+
*/
|
|
224
|
+
export interface CompressOptions {
|
|
225
|
+
/**
|
|
226
|
+
* Quality preset: `"low"` (smallest file), `"medium"` (balanced), `"high"` (best quality).
|
|
227
|
+
* Maps to CRF 28, 23, 18 respectively. Ignored when `bitrate` is set.
|
|
228
|
+
*/
|
|
229
|
+
quality: string;
|
|
230
|
+
/** Explicit target bitrate in bits per second. Overrides `quality` when set. `-1` to use quality preset. */
|
|
231
|
+
bitrate: number;
|
|
232
|
+
/** Target width in pixels. `-1` to keep original. Height is auto-calculated to preserve aspect ratio. */
|
|
233
|
+
width: number;
|
|
234
|
+
/** Target height in pixels. `-1` to keep original. Width is auto-calculated to preserve aspect ratio. */
|
|
235
|
+
height: number;
|
|
236
|
+
/** Target frame rate. `-1` to keep original. */
|
|
237
|
+
frameRate: number;
|
|
238
|
+
/** Output file extension (e.g. `"mp4"`). Default `"mp4"`. */
|
|
239
|
+
outputExt: string;
|
|
240
|
+
/** When `true`, strips the audio track from the output. Default `false`. */
|
|
241
|
+
removeAudio: boolean;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Result returned by {@link Spec.compress}.
|
|
245
|
+
*/
|
|
246
|
+
export interface CompressResult {
|
|
247
|
+
/** Absolute path to the compressed output file. */
|
|
248
|
+
outputPath: string;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Options for converting a video segment to an animated GIF.
|
|
252
|
+
*/
|
|
253
|
+
export interface GifOptions {
|
|
254
|
+
/** Start time in milliseconds. Default `0`. */
|
|
255
|
+
startTime: number;
|
|
256
|
+
/** End time in milliseconds. Default `-1` (end of video). */
|
|
257
|
+
endTime: number;
|
|
258
|
+
/** Frame rate of the GIF. Default `10`. */
|
|
259
|
+
fps: number;
|
|
260
|
+
/** Width in pixels. Height is auto-calculated to preserve aspect ratio. `-1` for original. */
|
|
261
|
+
width: number;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Result returned by {@link Spec.toGif}.
|
|
265
|
+
*/
|
|
266
|
+
export interface GifResult {
|
|
267
|
+
/** Absolute path to the generated GIF file. */
|
|
268
|
+
outputPath: string;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Options for merging multiple media files into one.
|
|
272
|
+
*/
|
|
273
|
+
export interface MergeOptions {
|
|
274
|
+
/** Output file extension (e.g. `"mp4"`, `"wav"`). Default `"mp4"`. */
|
|
275
|
+
outputExt: string;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Result returned by {@link Spec.merge}.
|
|
279
|
+
*/
|
|
280
|
+
export interface MergeResult {
|
|
281
|
+
/** Absolute path to the merged output file. */
|
|
282
|
+
outputPath: string;
|
|
283
|
+
/** Total duration of the merged file in milliseconds. */
|
|
284
|
+
duration: number;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Result returned by {@link Spec.saveToPhoto}.
|
|
288
|
+
*/
|
|
289
|
+
export interface SaveToPhotoResult {
|
|
290
|
+
/** Whether the file was saved to the photo library successfully. */
|
|
291
|
+
success: boolean;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Result returned by {@link Spec.saveToDocuments}.
|
|
295
|
+
*/
|
|
296
|
+
export interface SaveToDocumentsResult {
|
|
297
|
+
/** Whether the file was saved to documents successfully. */
|
|
298
|
+
success: boolean;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Result returned by {@link Spec.share}.
|
|
302
|
+
*/
|
|
303
|
+
export interface ShareResult {
|
|
304
|
+
/** Whether the user completed the share action. */
|
|
305
|
+
success: boolean;
|
|
306
|
+
}
|
|
175
307
|
/**
|
|
176
308
|
* TurboModule spec for the native VideoTrim module.
|
|
177
309
|
*/
|
|
@@ -190,6 +322,22 @@ export interface Spec extends TurboModule {
|
|
|
190
322
|
isValidFile(url: string): Promise<FileValidationResult>;
|
|
191
323
|
/** Perform a headless trim (no UI) on the given URL with the specified options. */
|
|
192
324
|
trim(url: string, options: TrimOptions): Promise<TrimResult>;
|
|
325
|
+
/** Extract a single frame from a video at the specified timestamp. */
|
|
326
|
+
getFrameAt(url: string, options: FrameExtractionOptions): Promise<FrameResult>;
|
|
327
|
+
/** Extract the audio track from a video file into a separate audio file. */
|
|
328
|
+
extractAudio(url: string, options: ExtractAudioOptions): Promise<ExtractAudioResult>;
|
|
329
|
+
/** Compress a video file to reduce its size. */
|
|
330
|
+
compress(url: string, options: CompressOptions): Promise<CompressResult>;
|
|
331
|
+
/** Convert a video segment to an animated GIF. */
|
|
332
|
+
toGif(url: string, options: GifOptions): Promise<GifResult>;
|
|
333
|
+
/** Merge multiple media files into a single file. Headless only, no editor UI. */
|
|
334
|
+
merge(urls: ReadonlyArray<string>, options: MergeOptions): Promise<MergeResult>;
|
|
335
|
+
/** Save a file to the device's photo library. Requires photo library permission. */
|
|
336
|
+
saveToPhoto(filePath: string): Promise<SaveToPhotoResult>;
|
|
337
|
+
/** Present the system document picker to save a file to the user's chosen location. */
|
|
338
|
+
saveToDocuments(filePath: string): Promise<SaveToDocumentsResult>;
|
|
339
|
+
/** Open the system share sheet for a file. */
|
|
340
|
+
share(filePath: string): Promise<ShareResult>;
|
|
193
341
|
/** Emitted when the trim operation starts. */
|
|
194
342
|
readonly onStartTrimming: EventEmitter<void>;
|
|
195
343
|
/** Emitted when the user cancels an in-progress trim operation. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeVideoTrim.d.ts","sourceRoot":"","sources":["../../../src/NativeVideoTrim.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AAE9E;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,qEAAqE;IACrE,WAAW,EAAE,OAAO,CAAC;IACrB,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAC;IAClB,sFAAsF;IACtF,uBAAuB,EAAE,OAAO,CAAC;IACjC,8EAA8E;IAC9E,4B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