react-native-video-trim 3.0.9 → 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 +64 -61
- package/VideoTrim.podspec +24 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +77 -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 -4
- 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/margelo/nitro/videotrim/utils/VideoTrimmerUtil.java +157 -0
- package/android/src/main/java/com/{videotrim → margelo/nitro/videotrim}/widgets/VideoTrimmerView.java +44 -72
- package/ios/AssetLoader.swift +2 -2
- package/ios/ErrorCode.swift +2 -2
- package/ios/ProgressAlertController.swift +2 -2
- package/ios/VideoTrim.swift +38 -739
- 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 -600
- package/android/src/main/java/com/videotrim/VideoTrimPackage.java +0 -28
- package/android/src/main/java/com/videotrim/utils/VideoTrimmerUtil.java +0 -270
- 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 -41
package/ios/VideoTrimmer.swift
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
//
|
|
2
2
|
// VideoTrimmer.swift
|
|
3
|
-
//
|
|
3
|
+
// VideoTrim
|
|
4
4
|
//
|
|
5
|
-
// Created by Duc Trung Mai on
|
|
5
|
+
// Created by Duc Trung Mai on 20/5/25.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
8
|
import UIKit
|
|
@@ -870,4 +870,3 @@ fileprivate extension CGSize {
|
|
|
870
870
|
return CGRect(origin: .zero, size: self).applying(transform).size
|
|
871
871
|
}
|
|
872
872
|
}
|
|
873
|
-
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
//
|
|
2
|
+
// VideoTrimmerThumb.swift
|
|
3
|
+
// VideoTrim
|
|
4
|
+
//
|
|
5
|
+
// Created by Duc Trung Mai on 20/5/25.
|
|
6
|
+
//
|
|
7
|
+
|
|
1
8
|
import UIKit
|
|
2
9
|
|
|
3
10
|
@available(iOS 13.0, *)
|
|
4
11
|
class VideoTrimmerThumb: UIView {
|
|
5
12
|
private var isActive = false
|
|
6
|
-
|
|
13
|
+
|
|
7
14
|
private let leadingChevronImageView: UIImageView = {
|
|
8
15
|
let imageView = UIImageView(image: UIImage(systemName: "chevron.compact.left"))
|
|
9
16
|
imageView.contentMode = .scaleAspectFill
|
|
@@ -12,7 +19,7 @@ class VideoTrimmerThumb: UIView {
|
|
|
12
19
|
imageView.translatesAutoresizingMaskIntoConstraints = false
|
|
13
20
|
return imageView
|
|
14
21
|
}()
|
|
15
|
-
|
|
22
|
+
|
|
16
23
|
private let trailingChevronView: UIImageView = {
|
|
17
24
|
let imageView = UIImageView(image: UIImage(systemName: "chevron.compact.right"))
|
|
18
25
|
imageView.contentMode = .scaleAspectFill
|
|
@@ -21,13 +28,13 @@ class VideoTrimmerThumb: UIView {
|
|
|
21
28
|
imageView.translatesAutoresizingMaskIntoConstraints = false
|
|
22
29
|
return imageView
|
|
23
30
|
}()
|
|
24
|
-
|
|
31
|
+
|
|
25
32
|
private let wrapperView: UIView = {
|
|
26
33
|
let view = UIView()
|
|
27
34
|
view.translatesAutoresizingMaskIntoConstraints = false
|
|
28
35
|
return view
|
|
29
36
|
}()
|
|
30
|
-
|
|
37
|
+
|
|
31
38
|
private let leadingView: UIView = {
|
|
32
39
|
let view = UIView()
|
|
33
40
|
view.layer.cornerRadius = 6
|
|
@@ -36,7 +43,7 @@ class VideoTrimmerThumb: UIView {
|
|
|
36
43
|
view.translatesAutoresizingMaskIntoConstraints = false
|
|
37
44
|
return view
|
|
38
45
|
}()
|
|
39
|
-
|
|
46
|
+
|
|
40
47
|
private let trailingView: UIView = {
|
|
41
48
|
let view = UIView()
|
|
42
49
|
view.layer.cornerRadius = 6
|
|
@@ -45,61 +52,61 @@ class VideoTrimmerThumb: UIView {
|
|
|
45
52
|
view.translatesAutoresizingMaskIntoConstraints = false
|
|
46
53
|
return view
|
|
47
54
|
}()
|
|
48
|
-
|
|
55
|
+
|
|
49
56
|
private let topView: UIView = {
|
|
50
57
|
let view = UIView()
|
|
51
58
|
view.translatesAutoresizingMaskIntoConstraints = false
|
|
52
59
|
return view
|
|
53
60
|
}()
|
|
54
|
-
|
|
61
|
+
|
|
55
62
|
private let bottomView: UIView = {
|
|
56
63
|
let view = UIView()
|
|
57
64
|
view.translatesAutoresizingMaskIntoConstraints = false
|
|
58
65
|
return view
|
|
59
66
|
}()
|
|
60
|
-
|
|
67
|
+
|
|
61
68
|
let leadingGrabber: UIControl = {
|
|
62
69
|
let control = UIControl()
|
|
63
70
|
control.translatesAutoresizingMaskIntoConstraints = false
|
|
64
71
|
return control
|
|
65
72
|
}()
|
|
66
|
-
|
|
73
|
+
|
|
67
74
|
let trailingGrabber: UIControl = {
|
|
68
75
|
let control = UIControl()
|
|
69
76
|
control.translatesAutoresizingMaskIntoConstraints = false
|
|
70
77
|
return control
|
|
71
78
|
}()
|
|
72
|
-
|
|
79
|
+
|
|
73
80
|
let chevronWidth: CGFloat = 16
|
|
74
81
|
let edgeHeight: CGFloat = 4
|
|
75
|
-
|
|
82
|
+
|
|
76
83
|
override init(frame: CGRect) {
|
|
77
84
|
super.init(frame: frame)
|
|
78
85
|
setup()
|
|
79
86
|
}
|
|
80
|
-
|
|
87
|
+
|
|
81
88
|
required init?(coder: NSCoder) {
|
|
82
89
|
super.init(coder: coder)
|
|
83
90
|
setup()
|
|
84
91
|
}
|
|
85
|
-
|
|
92
|
+
|
|
86
93
|
private func setup() {
|
|
87
94
|
leadingView.addSubview(leadingChevronImageView)
|
|
88
95
|
trailingView.addSubview(trailingChevronView)
|
|
89
|
-
|
|
96
|
+
|
|
90
97
|
wrapperView.addSubview(leadingView)
|
|
91
98
|
wrapperView.addSubview(trailingView)
|
|
92
99
|
wrapperView.addSubview(topView)
|
|
93
100
|
wrapperView.addSubview(bottomView)
|
|
94
101
|
addSubview(wrapperView)
|
|
95
|
-
|
|
102
|
+
|
|
96
103
|
wrapperView.addSubview(leadingGrabber)
|
|
97
104
|
wrapperView.addSubview(trailingGrabber)
|
|
98
|
-
|
|
105
|
+
|
|
99
106
|
setupConstraints()
|
|
100
107
|
updateColor()
|
|
101
108
|
}
|
|
102
|
-
|
|
109
|
+
|
|
103
110
|
private func setupConstraints() {
|
|
104
111
|
NSLayoutConstraint.activate([
|
|
105
112
|
// Wrapper view constraints
|
|
@@ -107,49 +114,49 @@ class VideoTrimmerThumb: UIView {
|
|
|
107
114
|
wrapperView.bottomAnchor.constraint(equalTo: self.bottomAnchor),
|
|
108
115
|
wrapperView.leadingAnchor.constraint(equalTo: self.leadingAnchor),
|
|
109
116
|
wrapperView.trailingAnchor.constraint(equalTo: self.trailingAnchor),
|
|
110
|
-
|
|
117
|
+
|
|
111
118
|
// Leading view constraints
|
|
112
119
|
leadingView.topAnchor.constraint(equalTo: wrapperView.topAnchor),
|
|
113
120
|
leadingView.bottomAnchor.constraint(equalTo: wrapperView.bottomAnchor),
|
|
114
121
|
leadingView.leadingAnchor.constraint(equalTo: wrapperView.leadingAnchor),
|
|
115
122
|
leadingView.widthAnchor.constraint(equalToConstant: chevronWidth),
|
|
116
|
-
|
|
123
|
+
|
|
117
124
|
// Trailing view constraints
|
|
118
125
|
trailingView.topAnchor.constraint(equalTo: wrapperView.topAnchor),
|
|
119
126
|
trailingView.bottomAnchor.constraint(equalTo: wrapperView.bottomAnchor),
|
|
120
127
|
trailingView.trailingAnchor.constraint(equalTo: wrapperView.trailingAnchor),
|
|
121
128
|
trailingView.widthAnchor.constraint(equalToConstant: chevronWidth),
|
|
122
|
-
|
|
129
|
+
|
|
123
130
|
// Top view constraints
|
|
124
131
|
topView.topAnchor.constraint(equalTo: wrapperView.topAnchor),
|
|
125
132
|
topView.leadingAnchor.constraint(equalTo: leadingView.trailingAnchor),
|
|
126
133
|
topView.trailingAnchor.constraint(equalTo: trailingView.leadingAnchor),
|
|
127
134
|
topView.heightAnchor.constraint(equalToConstant: edgeHeight),
|
|
128
|
-
|
|
135
|
+
|
|
129
136
|
// Bottom view constraints
|
|
130
137
|
bottomView.bottomAnchor.constraint(equalTo: wrapperView.bottomAnchor),
|
|
131
138
|
bottomView.leadingAnchor.constraint(equalTo: leadingView.trailingAnchor),
|
|
132
139
|
bottomView.trailingAnchor.constraint(equalTo: trailingView.leadingAnchor),
|
|
133
140
|
bottomView.heightAnchor.constraint(equalToConstant: edgeHeight),
|
|
134
|
-
|
|
141
|
+
|
|
135
142
|
// Leading Chevron ImageView constraints
|
|
136
143
|
leadingChevronImageView.topAnchor.constraint(equalTo: leadingView.topAnchor, constant: 8),
|
|
137
144
|
leadingChevronImageView.bottomAnchor.constraint(equalTo: leadingView.bottomAnchor, constant: -8),
|
|
138
145
|
leadingChevronImageView.leadingAnchor.constraint(equalTo: leadingView.leadingAnchor, constant: 2),
|
|
139
146
|
leadingChevronImageView.trailingAnchor.constraint(equalTo: leadingView.trailingAnchor, constant: -2),
|
|
140
|
-
|
|
147
|
+
|
|
141
148
|
// Trailing Chevron ImageView constraints
|
|
142
149
|
trailingChevronView.topAnchor.constraint(equalTo: trailingView.topAnchor, constant: 8),
|
|
143
150
|
trailingChevronView.bottomAnchor.constraint(equalTo: trailingView.bottomAnchor, constant: -8),
|
|
144
151
|
trailingChevronView.leadingAnchor.constraint(equalTo: trailingView.leadingAnchor, constant: 2),
|
|
145
152
|
trailingChevronView.trailingAnchor.constraint(equalTo: trailingView.trailingAnchor, constant: -2),
|
|
146
|
-
|
|
153
|
+
|
|
147
154
|
// Leading Grabber constraints
|
|
148
155
|
leadingGrabber.topAnchor.constraint(equalTo: leadingView.topAnchor),
|
|
149
156
|
leadingGrabber.bottomAnchor.constraint(equalTo: leadingView.bottomAnchor),
|
|
150
157
|
leadingGrabber.leadingAnchor.constraint(equalTo: leadingView.leadingAnchor),
|
|
151
158
|
leadingGrabber.trailingAnchor.constraint(equalTo: leadingView.trailingAnchor),
|
|
152
|
-
|
|
159
|
+
|
|
153
160
|
// Trailing Grabber constraints
|
|
154
161
|
trailingGrabber.topAnchor.constraint(equalTo: trailingView.topAnchor),
|
|
155
162
|
trailingGrabber.bottomAnchor.constraint(equalTo: trailingView.bottomAnchor),
|
|
@@ -157,7 +164,7 @@ class VideoTrimmerThumb: UIView {
|
|
|
157
164
|
trailingGrabber.trailingAnchor.constraint(equalTo: trailingView.trailingAnchor)
|
|
158
165
|
])
|
|
159
166
|
}
|
|
160
|
-
|
|
167
|
+
|
|
161
168
|
private func updateColor() {
|
|
162
169
|
let color = UIColor.systemYellow
|
|
163
170
|
leadingView.backgroundColor = color
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
//
|
|
2
|
+
// VideoTrimmerViewController.swift
|
|
3
|
+
// VideoTrim
|
|
4
|
+
//
|
|
5
|
+
// Created by Duc Trung Mai on 20/5/25.
|
|
6
|
+
//
|
|
7
|
+
|
|
1
8
|
import UIKit
|
|
2
9
|
import AVKit
|
|
3
10
|
|
|
@@ -60,7 +67,7 @@ class VideoTrimmerViewController: UIViewController {
|
|
|
60
67
|
private var jumpToPositionOnLoad: Double = 0;
|
|
61
68
|
private var headerText: String?
|
|
62
69
|
private var headerTextSize = 16
|
|
63
|
-
private var headerTextColor:
|
|
70
|
+
private var headerTextColor: Double?
|
|
64
71
|
private var headerView: UIView?
|
|
65
72
|
|
|
66
73
|
var isSeekInProgress: Bool = false // Marker
|
|
@@ -224,7 +231,7 @@ class VideoTrimmerViewController: UIViewController {
|
|
|
224
231
|
let headerTextView = UITextView()
|
|
225
232
|
headerTextView.text = headerText
|
|
226
233
|
headerTextView.textAlignment = .center
|
|
227
|
-
headerTextView.textColor = headerTextColor
|
|
234
|
+
headerTextView.textColor = UIColor.color(fromHexNumber: headerTextColor as NSNumber?, defaultColor: .white)
|
|
228
235
|
headerTextView.font = UIFont.systemFont(ofSize: CGFloat(headerTextSize)) // Set font size here
|
|
229
236
|
headerTextView.translatesAutoresizingMaskIntoConstraints = false
|
|
230
237
|
headerView!.addSubview(headerTextView)
|
|
@@ -435,39 +442,28 @@ class VideoTrimmerViewController: UIViewController {
|
|
|
435
442
|
}
|
|
436
443
|
}
|
|
437
444
|
|
|
438
|
-
public func configure(config:
|
|
439
|
-
if
|
|
440
|
-
maximumDuration = maxDuration
|
|
445
|
+
public func configure(config: EditorConfig) {
|
|
446
|
+
if config.maxDuration > 0 {
|
|
447
|
+
maximumDuration = Int(config.maxDuration)
|
|
441
448
|
}
|
|
442
449
|
|
|
443
|
-
if
|
|
444
|
-
minimumDuration = minDuration
|
|
450
|
+
if config.minDuration > 0 {
|
|
451
|
+
minimumDuration = Int(config.minDuration)
|
|
445
452
|
}
|
|
446
453
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
454
|
+
self.cancelButtonText = config.cancelButtonText
|
|
455
|
+
self.saveButtonText = config.saveButtonText
|
|
456
|
+
self.jumpToPositionOnLoad = config.jumpToPositionOnLoad
|
|
450
457
|
|
|
451
|
-
if let saveButtonText = config["saveButtonText"] as? String, !saveButtonText.isEmpty {
|
|
452
|
-
self.saveButtonText = saveButtonText
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
if let jumpToPositionOnLoad = config["jumpToPositionOnLoad"] as? Int {
|
|
456
|
-
self.jumpToPositionOnLoad = Double(jumpToPositionOnLoad)
|
|
457
|
-
}
|
|
458
458
|
|
|
459
|
-
enableHapticFeedback = config
|
|
460
|
-
autoplay = config
|
|
459
|
+
enableHapticFeedback = config.enableHapticFeedback
|
|
460
|
+
autoplay = config.autoplay
|
|
461
461
|
|
|
462
|
-
if
|
|
463
|
-
self.
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
if let headerText = config["headerText"] as? String, !headerText.isEmpty {
|
|
467
|
-
self.headerText = headerText
|
|
462
|
+
if !config.headerText.isEmpty {
|
|
463
|
+
self.headerText = config.headerText
|
|
468
464
|
|
|
469
|
-
headerTextSize = config
|
|
470
|
-
headerTextColor = config
|
|
465
|
+
headerTextSize = Int(config.headerTextSize)
|
|
466
|
+
headerTextColor = config.headerTextColor
|
|
471
467
|
}
|
|
472
468
|
}
|
|
473
469
|
|
|
@@ -485,7 +481,7 @@ class VideoTrimmerViewController: UIViewController {
|
|
|
485
481
|
self.saveBtn.alpha = 1
|
|
486
482
|
self.saveBtn.isEnabled = true
|
|
487
483
|
})
|
|
488
|
-
|
|
484
|
+
|
|
489
485
|
if jumpToPositionOnLoad > 0 {
|
|
490
486
|
let duration = (asset?.duration.seconds ?? 0) * 1000
|
|
491
487
|
let time = jumpToPositionOnLoad > duration ? duration : jumpToPositionOnLoad
|
|
@@ -536,3 +532,26 @@ private extension UILabel {
|
|
|
536
532
|
return label
|
|
537
533
|
}
|
|
538
534
|
}
|
|
535
|
+
|
|
536
|
+
extension UIColor {
|
|
537
|
+
static func color(fromHexNumber hex: NSNumber?, defaultColor: UIColor = .black) -> UIColor {
|
|
538
|
+
guard let hexValue = hex?.int32Value else {
|
|
539
|
+
return defaultColor
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
// Extract RGB components from the hex value
|
|
543
|
+
let red = CGFloat((hexValue >> 16) & 0xFF) / 255.0 // Extract red (bits 16-23)
|
|
544
|
+
let green = CGFloat((hexValue >> 8) & 0xFF) / 255.0 // Extract green (bits 8-15)
|
|
545
|
+
let blue = CGFloat(hexValue & 0xFF) / 255.0 // Extract blue (bits 0-7)
|
|
546
|
+
|
|
547
|
+
// Check if alpha is included (if hex is 0xAARRGGBB)
|
|
548
|
+
let alpha: CGFloat
|
|
549
|
+
if hexValue > 0xFFFFFF { // If the value is larger than 0xFFFFFF, it includes alpha
|
|
550
|
+
alpha = CGFloat((hexValue >> 24) & 0xFF) / 255.0 // Extract alpha (bits 24-31)
|
|
551
|
+
} else {
|
|
552
|
+
alpha = 1.0 // Default to opaque
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
return UIColor(red: red, green: green, blue: blue, alpha: alpha)
|
|
556
|
+
}
|
|
557
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["VideoTrim.nitro.ts"],"mappings":"","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -1,13 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { NitroModules } from 'react-native-nitro-modules';
|
|
4
|
+
import { processColor } from 'react-native';
|
|
5
|
+
const VideoTrimHybridObject = NitroModules.createHybridObject('VideoTrim');
|
|
6
|
+
function createEditorConfig(overrides = {}) {
|
|
7
|
+
return {
|
|
8
|
+
enableHapticFeedback: true,
|
|
9
|
+
saveToPhoto: false,
|
|
10
|
+
maxDuration: -1,
|
|
11
|
+
// Adjust default as needed
|
|
12
|
+
minDuration: 1000,
|
|
13
|
+
cancelButtonText: 'Cancel',
|
|
14
|
+
saveButtonText: 'Save',
|
|
15
|
+
enableCancelDialog: true,
|
|
16
|
+
cancelDialogTitle: 'Warning!',
|
|
17
|
+
cancelDialogMessage: 'Are you sure want to cancel?',
|
|
18
|
+
cancelDialogCancelText: 'Close',
|
|
19
|
+
cancelDialogConfirmText: 'Proceed',
|
|
20
|
+
enableSaveDialog: true,
|
|
21
|
+
saveDialogTitle: 'Confirmation!',
|
|
22
|
+
saveDialogMessage: 'Are you sure want to save?',
|
|
23
|
+
saveDialogCancelText: 'Close',
|
|
24
|
+
saveDialogConfirmText: 'Proceed',
|
|
25
|
+
trimmingText: 'Trimming video...',
|
|
26
|
+
fullScreenModalIOS: false,
|
|
27
|
+
type: 'video',
|
|
28
|
+
outputExt: 'mp4',
|
|
29
|
+
openDocumentsOnFinish: false,
|
|
30
|
+
openShareSheetOnFinish: false,
|
|
31
|
+
removeAfterSavedToPhoto: false,
|
|
32
|
+
removeAfterFailedToSavePhoto: false,
|
|
33
|
+
removeAfterSavedToDocuments: false,
|
|
34
|
+
removeAfterFailedToSaveDocuments: false,
|
|
35
|
+
removeAfterShared: false,
|
|
36
|
+
removeAfterFailedToShare: false,
|
|
37
|
+
autoplay: false,
|
|
38
|
+
// Adjust default as needed
|
|
39
|
+
jumpToPositionOnLoad: -1,
|
|
40
|
+
closeWhenFinish: true,
|
|
41
|
+
enableCancelTrimming: true,
|
|
42
|
+
cancelTrimmingButtonText: 'Cancel',
|
|
43
|
+
enableCancelTrimmingDialog: true,
|
|
44
|
+
cancelTrimmingDialogTitle: 'Warning!',
|
|
45
|
+
cancelTrimmingDialogMessage: 'Are you sure want to cancel trimming?',
|
|
46
|
+
cancelTrimmingDialogCancelText: 'Close',
|
|
47
|
+
cancelTrimmingDialogConfirmText: 'Proceed',
|
|
48
|
+
headerText: '',
|
|
49
|
+
// Adjust default as needed
|
|
50
|
+
headerTextSize: 16,
|
|
51
|
+
headerTextColor: processColor('white'),
|
|
52
|
+
alertOnFailToLoad: true,
|
|
53
|
+
alertOnFailTitle: 'Error',
|
|
54
|
+
alertOnFailMessage: 'Fail to load media. Possibly invalid file or no network connection',
|
|
55
|
+
alertOnFailCloseText: 'Close',
|
|
56
|
+
...overrides
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function noop() {}
|
|
60
|
+
|
|
11
61
|
/**
|
|
12
62
|
* Delete a file
|
|
13
63
|
*
|
|
@@ -15,16 +65,15 @@ const VideoTrim = NativeModules.VideoTrim ? NativeModules.VideoTrim : new Proxy(
|
|
|
15
65
|
* @param {EditorConfig} config: editor configuration
|
|
16
66
|
* @returns {void} A **Promise** which resolves `void`
|
|
17
67
|
*/
|
|
18
|
-
export function showEditor(filePath) {
|
|
19
|
-
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
68
|
+
export function showEditor(filePath, config, onEvent) {
|
|
20
69
|
const {
|
|
21
70
|
headerTextColor
|
|
22
71
|
} = config;
|
|
23
|
-
const color = processColor(headerTextColor);
|
|
24
|
-
|
|
72
|
+
const color = processColor(headerTextColor || 'white');
|
|
73
|
+
VideoTrimHybridObject.showEditor(filePath, createEditorConfig({
|
|
25
74
|
...config,
|
|
26
75
|
headerTextColor: color
|
|
27
|
-
});
|
|
76
|
+
}), onEvent || noop);
|
|
28
77
|
}
|
|
29
78
|
|
|
30
79
|
/**
|
|
@@ -33,7 +82,7 @@ export function showEditor(filePath) {
|
|
|
33
82
|
* @returns {Promise<string[]>} A **Promise** which resolves to array of files
|
|
34
83
|
*/
|
|
35
84
|
export function listFiles() {
|
|
36
|
-
return
|
|
85
|
+
return VideoTrimHybridObject.listFiles();
|
|
37
86
|
}
|
|
38
87
|
|
|
39
88
|
/**
|
|
@@ -42,7 +91,7 @@ export function listFiles() {
|
|
|
42
91
|
* @returns {Promise} A **Promise** which resolves to number of deleted files
|
|
43
92
|
*/
|
|
44
93
|
export function cleanFiles() {
|
|
45
|
-
return
|
|
94
|
+
return VideoTrimHybridObject.cleanFiles();
|
|
46
95
|
}
|
|
47
96
|
|
|
48
97
|
/**
|
|
@@ -52,17 +101,17 @@ export function cleanFiles() {
|
|
|
52
101
|
* @returns {Promise} A **Promise** which resolves `true` if successful
|
|
53
102
|
*/
|
|
54
103
|
export function deleteFile(filePath) {
|
|
55
|
-
if (!
|
|
104
|
+
if (!filePath?.trim().length) {
|
|
56
105
|
throw new Error('File path cannot be empty!');
|
|
57
106
|
}
|
|
58
|
-
return
|
|
107
|
+
return VideoTrimHybridObject.deleteFile(filePath);
|
|
59
108
|
}
|
|
60
109
|
|
|
61
110
|
/**
|
|
62
111
|
* Close editor
|
|
63
112
|
*/
|
|
64
|
-
export function closeEditor() {
|
|
65
|
-
return
|
|
113
|
+
export function closeEditor(onComplete) {
|
|
114
|
+
return VideoTrimHybridObject.closeEditor(onComplete || noop);
|
|
66
115
|
}
|
|
67
116
|
|
|
68
117
|
/**
|
|
@@ -71,6 +120,6 @@ export function closeEditor() {
|
|
|
71
120
|
* @returns {Promise} A **Promise** which resolves file info if successful
|
|
72
121
|
*/
|
|
73
122
|
export function isValidFile(url) {
|
|
74
|
-
return
|
|
123
|
+
return VideoTrimHybridObject.isValidFile(url);
|
|
75
124
|
}
|
|
76
125
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["NitroModules","processColor","VideoTrimHybridObject","createHybridObject","createEditorConfig","overrides","enableHapticFeedback","saveToPhoto","maxDuration","minDuration","cancelButtonText","saveButtonText","enableCancelDialog","cancelDialogTitle","cancelDialogMessage","cancelDialogCancelText","cancelDialogConfirmText","enableSaveDialog","saveDialogTitle","saveDialogMessage","saveDialogCancelText","saveDialogConfirmText","trimmingText","fullScreenModalIOS","type","outputExt","openDocumentsOnFinish","openShareSheetOnFinish","removeAfterSavedToPhoto","removeAfterFailedToSavePhoto","removeAfterSavedToDocuments","removeAfterFailedToSaveDocuments","removeAfterShared","removeAfterFailedToShare","autoplay","jumpToPositionOnLoad","closeWhenFinish","enableCancelTrimming","cancelTrimmingButtonText","enableCancelTrimmingDialog","cancelTrimmingDialogTitle","cancelTrimmingDialogMessage","cancelTrimmingDialogCancelText","cancelTrimmingDialogConfirmText","headerText","headerTextSize","headerTextColor","alertOnFailToLoad","alertOnFailTitle","alertOnFailMessage","alertOnFailCloseText","noop","showEditor","filePath","config","onEvent","color","listFiles","cleanFiles","deleteFile","trim","length","Error","closeEditor","onComplete","isValidFile","url"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"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","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|