react-native-video-trim 5.0.1 → 5.0.3
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/utils/MediaMetadataUtil.java +18 -1
- package/android/src/main/java/com/videotrim/utils/StorageUtil.java +6 -0
- package/android/src/main/java/com/videotrim/widgets/VideoTrimmerView.java +1 -1
- package/ios/ProgressAlertController.h +2 -5
- package/ios/ProgressAlertController.mm +32 -4
- package/package.json +1 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
package com.videotrim.utils;
|
|
2
2
|
|
|
3
3
|
import android.media.MediaMetadataRetriever;
|
|
4
|
+
import android.net.Uri;
|
|
4
5
|
import android.util.Log;
|
|
5
6
|
|
|
7
|
+
import java.io.File;
|
|
6
8
|
import java.io.IOException;
|
|
7
9
|
import java.util.HashMap;
|
|
8
10
|
|
|
@@ -17,7 +19,22 @@ public class MediaMetadataUtil {
|
|
|
17
19
|
if (source.startsWith("http://") || source.startsWith("https://")) {
|
|
18
20
|
retriever.setDataSource(source, new HashMap<>());
|
|
19
21
|
} else {
|
|
20
|
-
|
|
22
|
+
String filePath = source;
|
|
23
|
+
|
|
24
|
+
// if "source" is not a valid file path, try to parse it as a URI
|
|
25
|
+
if (!StorageUtil.isFileExists(filePath)) {
|
|
26
|
+
Log.e(TAG, "File does not exist, trying to parse as URI: " + source);
|
|
27
|
+
|
|
28
|
+
Uri uri = Uri.parse(source);
|
|
29
|
+
filePath = uri.getPath();
|
|
30
|
+
|
|
31
|
+
if (!StorageUtil.isFileExists(filePath)) {
|
|
32
|
+
Log.e(TAG, "File does not exist at path: " + filePath);
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
retriever.setDataSource(filePath);
|
|
21
38
|
}
|
|
22
39
|
return retriever;
|
|
23
40
|
} catch (Exception e) {
|
|
@@ -27,6 +27,12 @@ public class StorageUtil {
|
|
|
27
27
|
return file.getAbsolutePath();
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
public static boolean isFileExists(String filePath) {
|
|
31
|
+
if (TextUtils.isEmpty(filePath)) return false;
|
|
32
|
+
File file = new File(filePath);
|
|
33
|
+
return file.exists();
|
|
34
|
+
}
|
|
35
|
+
|
|
30
36
|
public static String[] listFiles(Context context) {
|
|
31
37
|
File filesDir = context.getFilesDir();
|
|
32
38
|
File[] files = filesDir.listFiles((dir, name) -> name.startsWith(VideoTrimmerUtil.FILE_PREFIX));
|
|
@@ -270,7 +270,7 @@ public class VideoTrimmerView extends FrameLayout implements IVideoTrimmerView {
|
|
|
270
270
|
|
|
271
271
|
VideoTrimmerUtil.SCREEN_WIDTH_FULL = this.getScreenWidthInPortraitMode();
|
|
272
272
|
VideoTrimmerUtil.VIDEO_FRAMES_WIDTH = VideoTrimmerUtil.SCREEN_WIDTH_FULL - RECYCLER_VIEW_PADDING * 2;
|
|
273
|
-
VideoTrimmerUtil.MAX_COUNT_RANGE = Math.max((VIDEO_FRAMES_WIDTH / VideoTrimmerUtil.mThumbWidth), VideoTrimmerUtil.MAX_COUNT_RANGE);
|
|
273
|
+
VideoTrimmerUtil.MAX_COUNT_RANGE = VideoTrimmerUtil.mThumbWidth != 0 ? Math.max((VIDEO_FRAMES_WIDTH / VideoTrimmerUtil.mThumbWidth), VideoTrimmerUtil.MAX_COUNT_RANGE) : VideoTrimmerUtil.MAX_COUNT_RANGE;
|
|
274
274
|
|
|
275
275
|
startShootVideoThumbs(mContext, VideoTrimmerUtil.MAX_COUNT_RANGE, 0, mDuration);
|
|
276
276
|
}
|
|
@@ -3,12 +3,9 @@
|
|
|
3
3
|
@interface ProgressAlertController : UIViewController
|
|
4
4
|
|
|
5
5
|
@property (nonatomic, copy) void (^onDismiss)(void);
|
|
6
|
-
@property (nonatomic, strong) UILabel *titleLabel;
|
|
7
|
-
@property (nonatomic, strong) UIProgressView *progressBar;
|
|
8
|
-
@property (nonatomic, strong) UIButton *actionButton;
|
|
9
6
|
|
|
10
|
-
- (void)setTitle:(NSString *)
|
|
11
|
-
- (void)setCancelTitle:(NSString *)
|
|
7
|
+
- (void)setTitle:(NSString *)text;
|
|
8
|
+
- (void)setCancelTitle:(NSString *)text;
|
|
12
9
|
- (void)setProgress:(float)progress;
|
|
13
10
|
- (void)showCancelBtn;
|
|
14
11
|
|
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
#import "ProgressAlertController.h"
|
|
2
2
|
|
|
3
|
+
@interface ProgressAlertController ()
|
|
4
|
+
|
|
5
|
+
@property (nonatomic, strong) UILabel *titleLabel;
|
|
6
|
+
@property (nonatomic, strong) UIProgressView *progressBar;
|
|
7
|
+
@property (nonatomic, strong) UIButton *actionButton;
|
|
8
|
+
|
|
9
|
+
@end
|
|
10
|
+
|
|
3
11
|
@implementation ProgressAlertController
|
|
4
12
|
|
|
13
|
+
- (instancetype)init {
|
|
14
|
+
// init early because in VideoTrim.mm we call this before presenting the view controller (before viewDidLoad)
|
|
15
|
+
if (self = [super init]) {
|
|
16
|
+
self.titleLabel = [[UILabel alloc] init];
|
|
17
|
+
self.progressBar = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault];
|
|
18
|
+
self.actionButton = [UIButton buttonWithType:UIButtonTypeSystem];
|
|
19
|
+
}
|
|
20
|
+
return self;
|
|
21
|
+
}
|
|
22
|
+
|
|
5
23
|
- (void)viewDidLoad {
|
|
6
24
|
[super viewDidLoad];
|
|
7
25
|
[self setupBackground];
|
|
@@ -14,26 +32,32 @@
|
|
|
14
32
|
|
|
15
33
|
- (void)setupAlertView {
|
|
16
34
|
UIView *alertView = [[UIView alloc] init];
|
|
17
|
-
alertView.backgroundColor = [UIColor colorWithRed:28/255.0 green:28/255.0 blue:30/255.0 alpha:1.0];
|
|
35
|
+
alertView.backgroundColor = [UIColor colorWithRed:28.0/255.0 green:28.0/255.0 blue:30.0/255.0 alpha:1.0];
|
|
18
36
|
alertView.layer.cornerRadius = 12;
|
|
19
37
|
alertView.translatesAutoresizingMaskIntoConstraints = NO;
|
|
20
38
|
[self.view addSubview:alertView];
|
|
39
|
+
|
|
40
|
+
// AlertView Constraints
|
|
21
41
|
[NSLayoutConstraint activateConstraints:@[
|
|
22
42
|
[alertView.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor],
|
|
23
43
|
[alertView.centerYAnchor constraintEqualToAnchor:self.view.centerYAnchor],
|
|
24
44
|
[alertView.widthAnchor constraintEqualToConstant:270]
|
|
25
45
|
]];
|
|
26
|
-
|
|
46
|
+
|
|
47
|
+
// Title Label
|
|
27
48
|
self.titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
|
|
28
49
|
self.titleLabel.textAlignment = NSTextAlignmentCenter;
|
|
29
50
|
self.titleLabel.font = [UIFont systemFontOfSize:18];
|
|
30
51
|
self.titleLabel.numberOfLines = 0;
|
|
31
52
|
self.titleLabel.textColor = [UIColor whiteColor];
|
|
32
53
|
[alertView addSubview:self.titleLabel];
|
|
33
|
-
|
|
54
|
+
|
|
55
|
+
// Progress Bar
|
|
34
56
|
self.progressBar.translatesAutoresizingMaskIntoConstraints = NO;
|
|
35
57
|
[alertView addSubview:self.progressBar];
|
|
36
|
-
|
|
58
|
+
|
|
59
|
+
// Action Button
|
|
60
|
+
|
|
37
61
|
[self.actionButton setTitle:@"Cancel" forState:UIControlStateNormal];
|
|
38
62
|
[self.actionButton setTitleColor:[UIColor systemPinkColor] forState:UIControlStateNormal];
|
|
39
63
|
self.actionButton.titleLabel.font = [UIFont systemFontOfSize:16];
|
|
@@ -41,13 +65,17 @@
|
|
|
41
65
|
self.actionButton.translatesAutoresizingMaskIntoConstraints = NO;
|
|
42
66
|
self.actionButton.hidden = YES;
|
|
43
67
|
[alertView addSubview:self.actionButton];
|
|
68
|
+
|
|
69
|
+
// Constraints for titleLabel, progressBar, and actionButton
|
|
44
70
|
[NSLayoutConstraint activateConstraints:@[
|
|
45
71
|
[self.titleLabel.topAnchor constraintEqualToAnchor:alertView.topAnchor constant:16],
|
|
46
72
|
[self.titleLabel.leadingAnchor constraintEqualToAnchor:alertView.leadingAnchor constant:16],
|
|
47
73
|
[self.titleLabel.trailingAnchor constraintEqualToAnchor:alertView.trailingAnchor constant:-16],
|
|
74
|
+
|
|
48
75
|
[self.progressBar.topAnchor constraintEqualToAnchor:self.titleLabel.bottomAnchor constant:16],
|
|
49
76
|
[self.progressBar.leadingAnchor constraintEqualToAnchor:alertView.leadingAnchor constant:16],
|
|
50
77
|
[self.progressBar.trailingAnchor constraintEqualToAnchor:alertView.trailingAnchor constant:-16],
|
|
78
|
+
|
|
51
79
|
[self.actionButton.topAnchor constraintEqualToAnchor:self.progressBar.bottomAnchor constant:16],
|
|
52
80
|
[self.actionButton.bottomAnchor constraintEqualToAnchor:alertView.bottomAnchor constant:-16],
|
|
53
81
|
[self.actionButton.centerXAnchor constraintEqualToAnchor:alertView.centerXAnchor]
|