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/android/src/main/java/com/{videotrim → margelo/nitro/videotrim}/utils/StorageUtil.java
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
package com.videotrim.utils;
|
|
1
|
+
package com.margelo.nitro.videotrim.utils;
|
|
2
2
|
|
|
3
3
|
import android.content.ContentValues;
|
|
4
4
|
import android.content.Context;
|
|
@@ -8,7 +8,9 @@ import android.os.Build;
|
|
|
8
8
|
import android.os.Environment;
|
|
9
9
|
import android.provider.MediaStore;
|
|
10
10
|
import android.text.TextUtils;
|
|
11
|
+
|
|
11
12
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
13
|
+
|
|
12
14
|
import java.io.File;
|
|
13
15
|
import java.io.FileInputStream;
|
|
14
16
|
import java.io.FileOutputStream;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
package com.margelo.nitro.videotrim.utils;
|
|
2
|
+
|
|
3
|
+
import android.annotation.SuppressLint;
|
|
4
|
+
import android.graphics.Bitmap;
|
|
5
|
+
import android.media.MediaMetadataRetriever;
|
|
6
|
+
import android.util.Log;
|
|
7
|
+
|
|
8
|
+
import com.arthenica.ffmpegkit.FFmpegKit;
|
|
9
|
+
import com.arthenica.ffmpegkit.FFmpegSession;
|
|
10
|
+
import com.arthenica.ffmpegkit.ReturnCode;
|
|
11
|
+
import com.arthenica.ffmpegkit.SessionState;
|
|
12
|
+
import com.margelo.nitro.videotrim.enums.ErrorCode;
|
|
13
|
+
import com.margelo.nitro.videotrim.interfaces.VideoTrimListener;
|
|
14
|
+
|
|
15
|
+
import java.text.SimpleDateFormat;
|
|
16
|
+
import java.util.Date;
|
|
17
|
+
import java.util.HashMap;
|
|
18
|
+
import java.util.Map;
|
|
19
|
+
import java.util.TimeZone;
|
|
20
|
+
|
|
21
|
+
import iknow.android.utils.DeviceUtil;
|
|
22
|
+
import iknow.android.utils.UnitConverter;
|
|
23
|
+
import iknow.android.utils.callback.SingleCallback;
|
|
24
|
+
import iknow.android.utils.thread.BackgroundExecutor;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
public class VideoTrimmerUtil {
|
|
28
|
+
|
|
29
|
+
private static final String TAG = VideoTrimmerUtil.class.getSimpleName();
|
|
30
|
+
public static final String FILE_PREFIX = "trimmedVideo";
|
|
31
|
+
public static final long MIN_SHOOT_DURATION = 1000L;// min 3 seconds for trimming
|
|
32
|
+
public static final int VIDEO_MAX_TIME = 10;// max 10 seconds for trimming
|
|
33
|
+
public static final long MAX_SHOOT_DURATION = VIDEO_MAX_TIME * 1000L;
|
|
34
|
+
// public static long maxShootDuration = 10 * 1000L;
|
|
35
|
+
public static int MAX_COUNT_RANGE = 10; // how many images in the highlight range of seek bar
|
|
36
|
+
public static int SCREEN_WIDTH_FULL = DeviceUtil.getDeviceWidth();
|
|
37
|
+
public static final int RECYCLER_VIEW_PADDING = UnitConverter.dpToPx(35);
|
|
38
|
+
public static String DEFAULT_AUDIO_EXTENSION = ".wav";
|
|
39
|
+
public static int VIDEO_FRAMES_WIDTH = SCREEN_WIDTH_FULL - RECYCLER_VIEW_PADDING * 2;
|
|
40
|
+
// public static final int THUMB_WIDTH = (SCREEN_WIDTH_FULL - RECYCLER_VIEW_PADDING * 2) / VIDEO_MAX_TIME;
|
|
41
|
+
public static int mThumbWidth = 0; // make it automatic
|
|
42
|
+
public static final int THUMB_HEIGHT = UnitConverter.dpToPx(50); // x2 for better resolution
|
|
43
|
+
public static final int THUMB_WIDTH = UnitConverter.dpToPx(25); // x2 for better resolution
|
|
44
|
+
private static final int THUMB_RESOLUTION_RES = 2; // double thumb resolution for better quality
|
|
45
|
+
|
|
46
|
+
public static FFmpegSession trim(String inputFile, String outputFile, int videoDuration, long startMs, long endMs, final VideoTrimListener callback) {
|
|
47
|
+
// Get the current date and time
|
|
48
|
+
Date currentDate = new Date();
|
|
49
|
+
|
|
50
|
+
// Create a SimpleDateFormat object with the desired format
|
|
51
|
+
@SuppressLint("SimpleDateFormat") SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
|
|
52
|
+
|
|
53
|
+
// Set the timezone to UTC
|
|
54
|
+
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
|
55
|
+
// Format the current date and time
|
|
56
|
+
String formattedDateTime = dateFormat.format(currentDate);
|
|
57
|
+
|
|
58
|
+
String[] cmds = {
|
|
59
|
+
"-ss",
|
|
60
|
+
startMs + "ms",
|
|
61
|
+
"-to",
|
|
62
|
+
endMs + "ms",
|
|
63
|
+
"-i",
|
|
64
|
+
inputFile,
|
|
65
|
+
"-c",
|
|
66
|
+
"copy",
|
|
67
|
+
"-metadata",
|
|
68
|
+
"creation_time=" + formattedDateTime,
|
|
69
|
+
outputFile
|
|
70
|
+
};
|
|
71
|
+
Log.d(TAG,"Command111: " + String.join(",", cmds));
|
|
72
|
+
|
|
73
|
+
FFmpegSession s = FFmpegKit.execute("-protocols");
|
|
74
|
+
Log.d(TAG, "1111getOutput: " + s.getOutput());
|
|
75
|
+
Log.d(TAG, "1111getAllLogs: " + s.getAllLogs());
|
|
76
|
+
|
|
77
|
+
return FFmpegKit.executeWithArgumentsAsync(cmds, session -> {
|
|
78
|
+
SessionState state = session.getState();
|
|
79
|
+
ReturnCode returnCode = session.getReturnCode();
|
|
80
|
+
if (ReturnCode.isSuccess(session.getReturnCode())) {
|
|
81
|
+
// SUCCESS
|
|
82
|
+
callback.onFinishTrim(outputFile, startMs, endMs, videoDuration);
|
|
83
|
+
} else if (ReturnCode.isCancel(session.getReturnCode())) {
|
|
84
|
+
// CANCEL
|
|
85
|
+
callback.onCancelTrim();
|
|
86
|
+
} else {
|
|
87
|
+
// FAILURE
|
|
88
|
+
String errorMessage = String.format("Command failed with state %s and rc %s.%s", state, returnCode, session.getFailStackTrace());
|
|
89
|
+
callback.onError(errorMessage, ErrorCode.TRIMMING_FAILED);
|
|
90
|
+
}
|
|
91
|
+
}, log -> {
|
|
92
|
+
Log.d(TAG, "FFmpeg process started with log " + log.getMessage());
|
|
93
|
+
|
|
94
|
+
Map<String, String> map = new HashMap<>();
|
|
95
|
+
map.put("level", String.valueOf(log.getLevel().getValue()));
|
|
96
|
+
map.put("message", log.getMessage());
|
|
97
|
+
map.put("sessionId", String.valueOf(log.getSessionId()));
|
|
98
|
+
map.put("logStr", log.toString());
|
|
99
|
+
|
|
100
|
+
callback.onLog(map);
|
|
101
|
+
}, statistics -> {
|
|
102
|
+
int timeInMilliseconds = (int) statistics.getTime();
|
|
103
|
+
if (timeInMilliseconds > 0) {
|
|
104
|
+
int completePercentage =
|
|
105
|
+
(timeInMilliseconds * 100) / videoDuration;
|
|
106
|
+
callback.onTrimmingProgress(Math.min(Math.max(completePercentage, 0), 100));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
Map<String, String> map = new HashMap<>();
|
|
110
|
+
map.put("sessionId", String.valueOf(statistics.getSessionId()));
|
|
111
|
+
map.put("videoFrameNumber", String.valueOf(statistics.getVideoFrameNumber()));
|
|
112
|
+
map.put("videoFps", String.valueOf(statistics.getVideoFps()));
|
|
113
|
+
map.put("videoQuality", String.valueOf(statistics.getVideoQuality()));
|
|
114
|
+
map.put("size", String.valueOf(statistics.getSize()));
|
|
115
|
+
map.put("time", String.valueOf(statistics.getTime()));
|
|
116
|
+
map.put("bitrate", String.valueOf(statistics.getBitrate()));
|
|
117
|
+
map.put("speed", String.valueOf(statistics.getSpeed()));
|
|
118
|
+
map.put("statisticsStr", statistics.toString());
|
|
119
|
+
callback.onStatistics(map);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
public static void shootVideoThumbInBackground(final MediaMetadataRetriever mediaMetadataRetriever, final int totalThumbsCount, final long startPosition,
|
|
124
|
+
final long endPosition, final SingleCallback<Bitmap, Integer> callback) {
|
|
125
|
+
BackgroundExecutor.execute(new BackgroundExecutor.Task("", 0L, "") {
|
|
126
|
+
@Override public void execute() {
|
|
127
|
+
try {
|
|
128
|
+
// Retrieve media data use microsecond
|
|
129
|
+
long interval = (endPosition - startPosition) / (totalThumbsCount - 1);
|
|
130
|
+
for (long i = 0; i < totalThumbsCount; ++i) {
|
|
131
|
+
long frameTime = startPosition + interval * i;
|
|
132
|
+
|
|
133
|
+
Bitmap bitmap;
|
|
134
|
+
try {
|
|
135
|
+
bitmap = mediaMetadataRetriever.getFrameAtTime(frameTime * 1000, MediaMetadataRetriever.OPTION_CLOSEST_SYNC);
|
|
136
|
+
} catch (final Throwable t) {
|
|
137
|
+
// this can happen while thumbnails are being generated in background and we press Cancel
|
|
138
|
+
t.printStackTrace();
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if(bitmap == null) continue;
|
|
143
|
+
try {
|
|
144
|
+
bitmap = Bitmap.createScaledBitmap(bitmap, mThumbWidth * THUMB_RESOLUTION_RES, THUMB_HEIGHT * THUMB_RESOLUTION_RES, false);
|
|
145
|
+
} catch (final Throwable t) {
|
|
146
|
+
t.printStackTrace();
|
|
147
|
+
}
|
|
148
|
+
callback.onSingleCallback(bitmap, (int) interval);
|
|
149
|
+
}
|
|
150
|
+
} catch (final Throwable e) {
|
|
151
|
+
Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
package com.videotrim.widgets;
|
|
1
|
+
package com.margelo.nitro.videotrim.widgets;
|
|
2
2
|
|
|
3
3
|
import static com.facebook.react.bridge.UiThreadUtil.runOnUiThread;
|
|
4
|
-
import static com.videotrim.utils.VideoTrimmerUtil.RECYCLER_VIEW_PADDING;
|
|
5
|
-
import static com.videotrim.utils.VideoTrimmerUtil.VIDEO_FRAMES_WIDTH;
|
|
4
|
+
import static com.margelo.nitro.videotrim.utils.VideoTrimmerUtil.RECYCLER_VIEW_PADDING;
|
|
5
|
+
import static com.margelo.nitro.videotrim.utils.VideoTrimmerUtil.VIDEO_FRAMES_WIDTH;
|
|
6
6
|
|
|
7
7
|
import android.content.Context;
|
|
8
8
|
import android.content.pm.ActivityInfo;
|
|
@@ -32,15 +32,16 @@ import android.widget.VideoView;
|
|
|
32
32
|
|
|
33
33
|
import androidx.appcompat.app.AlertDialog;
|
|
34
34
|
|
|
35
|
+
import com.arthenica.ffmpegkit.FFmpegSession;
|
|
35
36
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
36
|
-
import com.
|
|
37
|
-
import com.videotrim.R;
|
|
38
|
-
import com.videotrim.enums.ErrorCode;
|
|
39
|
-
import com.videotrim.interfaces.IVideoTrimmerView;
|
|
40
|
-
import com.videotrim.interfaces.VideoTrimListener;
|
|
41
|
-
import com.videotrim.utils.MediaMetadataUtil;
|
|
42
|
-
import com.videotrim.utils.StorageUtil;
|
|
43
|
-
import com.videotrim.utils.VideoTrimmerUtil;
|
|
37
|
+
import com.margelo.nitro.videotrim.EditorConfig;
|
|
38
|
+
import com.margelo.nitro.videotrim.R;
|
|
39
|
+
import com.margelo.nitro.videotrim.enums.ErrorCode;
|
|
40
|
+
import com.margelo.nitro.videotrim.interfaces.IVideoTrimmerView;
|
|
41
|
+
import com.margelo.nitro.videotrim.interfaces.VideoTrimListener;
|
|
42
|
+
import com.margelo.nitro.videotrim.utils.MediaMetadataUtil;
|
|
43
|
+
import com.margelo.nitro.videotrim.utils.StorageUtil;
|
|
44
|
+
import com.margelo.nitro.videotrim.utils.VideoTrimmerUtil;
|
|
44
45
|
|
|
45
46
|
import java.io.IOException;
|
|
46
47
|
import java.util.Locale;
|
|
@@ -108,23 +109,23 @@ public class VideoTrimmerView extends FrameLayout implements IVideoTrimmerView {
|
|
|
108
109
|
private long jumpToPositionOnLoad = 0;
|
|
109
110
|
private FrameLayout headerView;
|
|
110
111
|
private TextView headerText;
|
|
111
|
-
private
|
|
112
|
+
private FFmpegSession ffmpegSession;
|
|
112
113
|
private boolean alertOnFailToLoad = true;
|
|
113
114
|
private String alertOnFailTitle = "Error";
|
|
114
115
|
private String alertOnFailMessage = "Fail to load media. Possibly invalid file or no network connection";
|
|
115
116
|
private String alertOnFailCloseText = "Close";
|
|
116
117
|
private View currentSelectedhandle;
|
|
117
118
|
|
|
118
|
-
public VideoTrimmerView(ReactApplicationContext context,
|
|
119
|
+
public VideoTrimmerView(ReactApplicationContext context, EditorConfig config, AttributeSet attrs) {
|
|
119
120
|
this(context, attrs, 0, config);
|
|
120
121
|
}
|
|
121
122
|
|
|
122
|
-
public VideoTrimmerView(ReactApplicationContext context, AttributeSet attrs, int defStyleAttr,
|
|
123
|
+
public VideoTrimmerView(ReactApplicationContext context, AttributeSet attrs, int defStyleAttr, EditorConfig config) {
|
|
123
124
|
super(context, attrs, defStyleAttr);
|
|
124
125
|
init(context, config);
|
|
125
126
|
}
|
|
126
127
|
|
|
127
|
-
private void init(ReactApplicationContext context,
|
|
128
|
+
private void init(ReactApplicationContext context, EditorConfig config) {
|
|
128
129
|
this.mContext = context;
|
|
129
130
|
|
|
130
131
|
context.getCurrentActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
|
@@ -365,22 +366,21 @@ public class VideoTrimmerView extends FrameLayout implements IVideoTrimmerView {
|
|
|
365
366
|
setHandleTouchListener(trailingHandle, false);
|
|
366
367
|
}
|
|
367
368
|
|
|
368
|
-
public void onSaveClicked(
|
|
369
|
+
public void onSaveClicked() {
|
|
369
370
|
onMediaPause();
|
|
370
|
-
|
|
371
|
+
ffmpegSession = VideoTrimmerUtil.trim(
|
|
371
372
|
mSourceUri.toString(),
|
|
372
373
|
StorageUtil.getOutputPath(mContext, mOutputExt),
|
|
373
374
|
mDuration,
|
|
374
375
|
startTime,
|
|
375
376
|
endTime,
|
|
376
|
-
mOnTrimVideoListener
|
|
377
|
-
progressUpdateInterval
|
|
377
|
+
mOnTrimVideoListener
|
|
378
378
|
);
|
|
379
379
|
}
|
|
380
380
|
|
|
381
381
|
public void onCancelTrimClicked() {
|
|
382
|
-
if (
|
|
383
|
-
|
|
382
|
+
if (ffmpegSession != null) {
|
|
383
|
+
ffmpegSession.cancel();
|
|
384
384
|
} else {
|
|
385
385
|
mOnTrimVideoListener.onCancelTrim();
|
|
386
386
|
}
|
|
@@ -445,79 +445,51 @@ public class VideoTrimmerView extends FrameLayout implements IVideoTrimmerView {
|
|
|
445
445
|
return screenWidth;
|
|
446
446
|
}
|
|
447
447
|
|
|
448
|
-
private void configure(
|
|
449
|
-
if (config.
|
|
450
|
-
mMaxDuration = Math.max(0, config.
|
|
448
|
+
private void configure(EditorConfig config) {
|
|
449
|
+
if (config.getMaxDuration() > 0) {
|
|
450
|
+
mMaxDuration = (long) Math.max(0, config.getMaxDuration() * 1000L);
|
|
451
451
|
}
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
if (config.hasKey("cancelButtonText")) {
|
|
456
|
-
cancelBtn.setText(config.getString("cancelButtonText"));
|
|
457
|
-
}
|
|
458
|
-
if (config.hasKey("saveButtonText")) {
|
|
459
|
-
saveBtn.setText(config.getString("saveButtonText"));
|
|
452
|
+
|
|
453
|
+
if (config.getMinDuration() > 0) {
|
|
454
|
+
mMinDuration = (long) Math.max(1000L, config.getMinDuration() * 1000L);
|
|
460
455
|
}
|
|
461
456
|
|
|
462
|
-
|
|
463
|
-
isVideoType = !config.getString("type").equals("audio");
|
|
457
|
+
cancelBtn.setText(config.getCancelButtonText());
|
|
464
458
|
|
|
465
|
-
|
|
466
|
-
// mThumbnailContainer.setAlpha(0f);
|
|
467
|
-
// mThumbnailContainer.setBackground(ContextCompat.getDrawable(mContext, R.drawable.thumb_container_bg));
|
|
468
|
-
// }
|
|
469
|
-
}
|
|
459
|
+
saveBtn.setText(config.getSaveButtonText());
|
|
470
460
|
|
|
471
|
-
|
|
472
|
-
mOutputExt = config.getString("outputExt");
|
|
473
|
-
} else if (!isVideoType) {
|
|
474
|
-
mOutputExt = "wav";
|
|
475
|
-
}
|
|
461
|
+
isVideoType = config.getType().equals("video");
|
|
476
462
|
|
|
477
|
-
|
|
478
|
-
|
|
463
|
+
mOutputExt = config.getOutputExt();
|
|
464
|
+
if (!isVideoType) {
|
|
465
|
+
mOutputExt = "wav";
|
|
479
466
|
}
|
|
480
467
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
}
|
|
468
|
+
enableHapticFeedback = config.getEnableHapticFeedback();
|
|
469
|
+
autoplay = config.getAutoplay();
|
|
484
470
|
|
|
485
|
-
if (config.
|
|
486
|
-
jumpToPositionOnLoad = config.
|
|
471
|
+
if (config.getJumpToPositionOnLoad() > 0) {
|
|
472
|
+
jumpToPositionOnLoad = (long) config.getJumpToPositionOnLoad();
|
|
487
473
|
}
|
|
488
|
-
// check if config.getString("headerText") is not empty
|
|
489
474
|
|
|
490
|
-
|
|
491
|
-
headerText.setText(config.getString("headerText"));
|
|
475
|
+
headerText.setText(config.getHeaderText());
|
|
492
476
|
|
|
493
|
-
|
|
494
|
-
int textSize = config.getInt("headerTextSize");
|
|
477
|
+
int textSize = (int) config.getHeaderTextSize();
|
|
495
478
|
if (textSize < 0) {
|
|
496
479
|
textSize = 16;
|
|
497
480
|
}
|
|
498
481
|
headerText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize);
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
if (config.hasKey("headerTextColor")) {
|
|
502
|
-
headerText.setTextColor(config.getInt("headerTextColor"));
|
|
503
|
-
}
|
|
482
|
+
headerText.setTextColor((int) config.getHeaderTextColor());
|
|
504
483
|
|
|
505
484
|
headerView.setVisibility(View.VISIBLE);
|
|
506
|
-
}
|
|
507
485
|
|
|
508
|
-
alertOnFailToLoad =
|
|
486
|
+
alertOnFailToLoad = config.getAlertOnFailToLoad();
|
|
509
487
|
|
|
510
|
-
|
|
511
|
-
alertOnFailTitle = config.getString("alertOnFailTitle");
|
|
512
|
-
}
|
|
488
|
+
alertOnFailTitle = config.getAlertOnFailTitle();
|
|
513
489
|
|
|
514
|
-
|
|
515
|
-
alertOnFailMessage = config.getString("alertOnFailMessage");
|
|
516
|
-
}
|
|
490
|
+
alertOnFailMessage = config.getAlertOnFailMessage();
|
|
517
491
|
|
|
518
|
-
|
|
519
|
-
alertOnFailCloseText = config.getString("alertOnFailCloseText");
|
|
520
|
-
}
|
|
492
|
+
alertOnFailCloseText = config.getAlertOnFailCloseText();
|
|
521
493
|
}
|
|
522
494
|
|
|
523
495
|
private void startTimingRunnable() {
|
package/ios/AssetLoader.swift
CHANGED
package/ios/ErrorCode.swift
CHANGED