react-native-video-trim 1.0.7 → 1.0.9

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.
@@ -43,6 +43,22 @@ def supportsNamespace() {
43
43
  return major >= 8
44
44
  }
45
45
 
46
+ static def safePackageName(String packageName) {
47
+ packageName.replace("-lts", "")
48
+ }
49
+
50
+ def safePackageVersion(String packageName) {
51
+ def version = project.properties['ffmpegKit.android.main.version']
52
+ def ltsVersion = project.properties['ffmpegKit.android.lts.version']
53
+
54
+ // try to get ffmpegKitPackageVersion if possible
55
+ safeExtGet("ffmpegKitPackageVersion", packageName.contains("-lts") ? ltsVersion + ".LTS" : version)
56
+ }
57
+
58
+ def safeExtGet(String prop, String fallback) {
59
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
60
+ }
61
+
46
62
  android {
47
63
  if (supportsNamespace()) {
48
64
  namespace "com.videotrim"
@@ -90,7 +106,7 @@ dependencies {
90
106
  //noinspection GradleDynamicVersion
91
107
  implementation "com.facebook.react:react-native:+"
92
108
  implementation 'androidx.recyclerview:recyclerview:1.3.1'
93
- implementation 'com.arthenica:ffmpeg-kit-full:5.1.LTS'
109
+ implementation 'com.arthenica:ffmpeg-kit-' + safePackageName(safeExtGet('ffmpegKitPackage', 'min')) + ':' + safePackageVersion(safeExtGet('ffmpegKitPackage', 'min'))
94
110
  }
95
111
 
96
112
  if (isNewArchitectureEnabled()) {
@@ -3,3 +3,5 @@ VideoTrim_minSdkVersion=21
3
3
  VideoTrim_targetSdkVersion=31
4
4
  VideoTrim_compileSdkVersion=31
5
5
  VideoTrim_ndkversion=21.4.7075529
6
+ ffmpegKit.android.main.version=6.0-2
7
+ ffmpegKit.android.lts.version=6.0-2
@@ -222,15 +222,8 @@ public class StorageUtil {
222
222
  if (uri != null) {
223
223
  try {
224
224
  OutputStream outputStream = context.getContentResolver().openOutputStream(uri);
225
- if (outputStream != null) {
226
- // Copy the video file to the output stream
227
- // Here, you can use the method you have to copy the file contents
228
- // For example, you can use FileInputStream to read from videoFile and write to outputStream
229
-
230
- outputStream.close();
231
- // Notify the media scanner that a new video has been added to the gallery
232
- MediaScannerConnection.scanFile(context, new String[]{videoFile.getAbsolutePath()}, new String[]{"video/*"}, null);
233
- }
225
+ copyFile(videoFile, outputStream);
226
+ MediaScannerConnection.scanFile(context, new String[]{uri.toString()}, new String[]{"video/*"}, null);
234
227
  } catch (IOException e) {
235
228
  e.printStackTrace();
236
229
  }
@@ -245,14 +238,19 @@ public class StorageUtil {
245
238
  MediaScannerConnection.scanFile(context, new String[]{destinationFile.getAbsolutePath()}, new String[]{"video/*"}, null);
246
239
  }
247
240
 
241
+ private static void copyFile(File sourceFile, OutputStream outputStream) throws IOException {
242
+ InputStream inputStream = new FileInputStream(sourceFile);
243
+ copyFile(inputStream, outputStream);
244
+ }
245
+
248
246
  private static void copyFile(File sourceFile, File destFile) throws IOException {
249
- InputStream inputStream = null;
250
- OutputStream outputStream = null;
247
+ InputStream inputStream = new FileInputStream(sourceFile);
248
+ OutputStream outputStream = new FileOutputStream(destFile);
249
+ copyFile(inputStream, outputStream);
250
+ }
251
251
 
252
+ private static void copyFile(InputStream inputStream, OutputStream outputStream) throws IOException {
252
253
  try {
253
- inputStream = new FileInputStream(sourceFile);
254
- outputStream = new FileOutputStream(destFile);
255
-
256
254
  byte[] buffer = new byte[1024];
257
255
  int length;
258
256
  while ((length = inputStream.read(buffer)) > 0) {
@@ -59,7 +59,7 @@ public class VideoTrimmerUtil {
59
59
  }, log -> {
60
60
 
61
61
  }, statistics -> {
62
- int timeInMilliseconds = statistics.getTime();
62
+ int timeInMilliseconds = (int) statistics.getTime();
63
63
  if (timeInMilliseconds > 0) {
64
64
  int completePercentage =
65
65
  (timeInMilliseconds * 100) / videoDuration;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-video-trim",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "Video trimmer for your React Native app",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",