react-native-compressor 0.5.6 → 0.5.12
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 +29 -2
- package/android/.gradle/6.1.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/6.1.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/6.9/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/6.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/{6.1.1 → 6.9}/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/6.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/6.9/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/checksums/sha1-checksums.bin +0 -0
- package/android/.idea/jarRepositories.xml +10 -0
- package/android/.idea/libraries/Gradle__androidx_annotation_annotation_1_1_0.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_appcompat_appcompat_1_0_2_aar.xml +4 -0
- package/android/.idea/libraries/Gradle__androidx_arch_core_core_runtime_2_0_0_aar.xml +3 -0
- package/android/.idea/libraries/Gradle__androidx_asynclayoutinflater_asynclayoutinflater_1_0_0_aar.xml +3 -0
- package/android/.idea/libraries/Gradle__androidx_autofill_autofill_1_1_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_coordinatorlayout_coordinatorlayout_1_0_0_aar.xml +4 -0
- package/android/.idea/libraries/Gradle__androidx_core_core_1_1_0_aar.xml +16 -0
- package/android/.idea/libraries/Gradle__androidx_cursoradapter_cursoradapter_1_0_0_aar.xml +3 -0
- package/android/.idea/libraries/Gradle__androidx_customview_customview_1_0_0_aar.xml +3 -0
- package/android/.idea/libraries/Gradle__androidx_documentfile_documentfile_1_0_0_aar.xml +3 -0
- package/android/.idea/libraries/Gradle__androidx_drawerlayout_drawerlayout_1_0_0_aar.xml +4 -0
- package/android/.idea/libraries/Gradle__androidx_fragment_fragment_1_0_0_aar.xml +4 -0
- package/android/.idea/libraries/Gradle__androidx_interpolator_interpolator_1_0_0_aar.xml +3 -0
- package/android/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_ui_1_0_0_aar.xml +3 -0
- package/android/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_utils_1_0_0_aar.xml +3 -0
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_2_0_0_aar.xml +3 -0
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_2_0_0_aar.xml +3 -0
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_2_0_0_aar.xml +3 -0
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_2_0_0_aar.xml +3 -0
- package/android/.idea/libraries/Gradle__androidx_loader_loader_1_0_0_aar.xml +3 -0
- package/android/.idea/libraries/Gradle__androidx_localbroadcastmanager_localbroadcastmanager_1_0_0_aar.xml +3 -0
- package/android/.idea/libraries/Gradle__androidx_print_print_1_0_0_aar.xml +4 -0
- package/android/.idea/libraries/Gradle__androidx_slidingpanelayout_slidingpanelayout_1_0_0_aar.xml +3 -0
- package/android/.idea/libraries/Gradle__androidx_swiperefreshlayout_swiperefreshlayout_1_0_0_aar.xml +4 -0
- package/android/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_1_0_1_aar.xml +3 -0
- package/android/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_animated_1_0_0_aar.xml +3 -0
- package/android/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_0_aar.xml +13 -0
- package/android/.idea/libraries/Gradle__androidx_viewpager_viewpager_1_0_0_aar.xml +3 -0
- package/android/.idea/libraries/Gradle__com_facebook_fbjni_fbjni_java_only_0_2_2.xml +13 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_drawee_2_5_0_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_fbcore_2_5_0_aar.xml +18 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_fresco_2_5_0_aar.xml +18 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_2_5_0_aar.xml +18 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_base_2_5_0_aar.xml +18 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_native_2_5_0_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_okhttp3_2_5_0_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_memory_type_ashmem_2_5_0_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_memory_type_java_2_5_0_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_memory_type_native_2_5_0_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_nativeimagefilters_2_5_0_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_nativeimagetranscoder_2_5_0_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_fresco_ui_common_2_5_0_aar.xml +15 -0
- package/android/.idea/libraries/{Gradle__com_facebook_infer_annotation_infer_annotation_0_11_2.xml → Gradle__com_facebook_infer_annotation_infer_annotation_0_18_0.xml} +4 -4
- package/android/.idea/libraries/Gradle__com_facebook_react_react_native_0_66_1_aar.xml +14 -0
- package/android/.idea/libraries/Gradle__com_facebook_soloader_annotation_0_10_1.xml +13 -0
- package/android/.idea/libraries/Gradle__com_facebook_soloader_nativeloader_0_10_1.xml +13 -0
- package/android/.idea/libraries/Gradle__com_facebook_soloader_soloader_0_10_1_aar.xml +15 -0
- package/android/.idea/libraries/Gradle__com_facebook_yoga_proguard_annotations_1_19_0.xml +13 -0
- package/android/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_4_9_1.xml +13 -0
- package/android/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_urlconnection_4_9_1.xml +13 -0
- package/android/.idea/libraries/Gradle__com_squareup_okio_okio_2_9_0.xml +13 -0
- package/android/.idea/libraries/Gradle__io_github_lizhangqu_coreprogress_1_0_2_aar.xml +5 -2
- package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_annotations_jvm_1_3_72.xml +13 -0
- package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_4_10.xml +13 -0
- package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_4_10.xml +13 -0
- package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk7_1_4_10.xml +13 -0
- package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk8_1_4_10.xml +13 -0
- package/android/.idea/modules/android.iml +34 -26
- package/android/build.gradle +6 -3
- package/android/src/main/java/com/reactnativecompressor/.DS_Store +0 -0
- package/android/src/main/java/com/reactnativecompressor/Audio/AudioCompressor.java +6 -1
- package/android/src/main/java/com/reactnativecompressor/CompressorModule.java +7 -3
- package/android/src/main/java/com/reactnativecompressor/Image/ImageCompressor.java +6 -14
- package/android/src/main/java/com/reactnativecompressor/Utils/Utils.java +68 -0
- package/android/src/main/java/com/reactnativecompressor/Video/AutoVideoCompression/AutoVideoCompression.java +3 -2
- package/android/src/main/java/com/reactnativecompressor/Video/VideoCompressorHelper.java +4 -0
- package/app.plugin.js +1 -0
- package/ios/Video/VideoCompressor.swift +22 -12
- package/lib/commonjs/Video/index.js +7 -3
- package/lib/commonjs/Video/index.js.map +1 -1
- package/lib/commonjs/expo-plugin/compressor.js +17 -0
- package/lib/commonjs/expo-plugin/compressor.js.map +1 -0
- package/lib/commonjs/index.js +8 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/index.js +13 -1
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/module/Video/index.js +5 -1
- package/lib/module/Video/index.js.map +1 -1
- package/lib/module/expo-plugin/compressor.js +8 -0
- package/lib/module/expo-plugin/compressor.js.map +1 -0
- package/lib/module/index.js +4 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/index.js +9 -0
- package/lib/module/utils/index.js.map +1 -1
- package/lib/typescript/Video/index.d.ts +2 -0
- package/lib/typescript/expo-plugin/compressor.d.ts +4 -0
- package/lib/typescript/index.d.ts +3 -2
- package/lib/typescript/utils/index.d.ts +1 -0
- package/package.json +4 -4
- package/src/Video/index.tsx +9 -1
- package/src/expo-plugin/compressor.ts +8 -0
- package/src/index.tsx +3 -1
- package/src/utils/index.tsx +17 -0
- package/android/.gradle/6.1.1/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.idea/libraries/Gradle__androidx_annotation_annotation_1_0_0.xml +0 -13
- package/android/.idea/libraries/Gradle__androidx_core_core_1_0_1_aar.xml +0 -20
- package/android/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_0_0_aar.xml +0 -16
- package/android/.idea/libraries/Gradle__com_facebook_fbjni_fbjni_java_only_0_0_3.xml +0 -13
- package/android/.idea/libraries/Gradle__com_facebook_fresco_drawee_2_0_0_aar.xml +0 -18
- package/android/.idea/libraries/Gradle__com_facebook_fresco_fbcore_2_0_0_aar.xml +0 -22
- package/android/.idea/libraries/Gradle__com_facebook_fresco_fresco_2_0_0_aar.xml +0 -22
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_2_0_0_aar.xml +0 -22
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_base_2_0_0_aar.xml +0 -22
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_okhttp3_2_0_0_aar.xml +0 -18
- package/android/.idea/libraries/Gradle__com_facebook_fresco_nativeimagefilters_2_0_0_aar.xml +0 -18
- package/android/.idea/libraries/Gradle__com_facebook_fresco_nativeimagetranscoder_2_0_0_aar.xml +0 -18
- package/android/.idea/libraries/Gradle__com_facebook_react_react_native_0_63_4_aar.xml +0 -22
- package/android/.idea/libraries/Gradle__com_facebook_soloader_annotation_0_9_0.xml +0 -13
- package/android/.idea/libraries/Gradle__com_facebook_soloader_nativeloader_0_9_0.xml +0 -13
- package/android/.idea/libraries/Gradle__com_facebook_soloader_soloader_0_9_0_aar.xml +0 -18
- package/android/.idea/libraries/Gradle__com_facebook_yoga_proguard_annotations_1_14_1.xml +0 -13
- package/android/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_3_12_12.xml +0 -13
- package/android/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_urlconnection_3_12_12.xml +0 -13
- package/android/.idea/libraries/Gradle__com_squareup_okio_okio_1_15_0.xml +0 -13
- package/android/.idea/libraries/Gradle__com_zolad_videoslimmer_1_0_0_aar.xml +0 -15
- package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_4_0.xml +0 -13
- package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_4_0.xml +0 -13
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
package com.reactnativecompressor;
|
|
2
2
|
|
|
3
|
-
import android.graphics.Bitmap;
|
|
4
3
|
import android.media.MediaMetadataRetriever;
|
|
5
4
|
import android.net.Uri;
|
|
6
5
|
import android.os.Build;
|
|
@@ -10,7 +9,6 @@ import androidx.annotation.NonNull;
|
|
|
10
9
|
import androidx.annotation.Nullable;
|
|
11
10
|
import androidx.annotation.RequiresApi;
|
|
12
11
|
|
|
13
|
-
import com.facebook.react.bridge.Arguments;
|
|
14
12
|
import com.facebook.react.bridge.Promise;
|
|
15
13
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
16
14
|
import com.facebook.react.bridge.ReactContext;
|
|
@@ -23,10 +21,12 @@ import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
|
23
21
|
import com.reactnativecompressor.Image.ImageCompressor;
|
|
24
22
|
import com.reactnativecompressor.Image.utils.ImageCompressorOptions;
|
|
25
23
|
import com.reactnativecompressor.Video.VideoCompressorHelper;
|
|
24
|
+
<<<<<<< HEAD
|
|
26
25
|
import com.zolad.videoslimmer.VideoSlimmer;
|
|
26
|
+
=======
|
|
27
|
+
>>>>>>> chore: add video compression cancel and fix stretch video
|
|
27
28
|
|
|
28
29
|
import static com.reactnativecompressor.Utils.Utils.generateCacheFilePath;
|
|
29
|
-
import java.io.ByteArrayOutputStream;
|
|
30
30
|
import com.reactnativecompressor.Audio.AudioCompressor;
|
|
31
31
|
|
|
32
32
|
@ReactModule(name = CompressorModule.NAME)
|
|
@@ -93,6 +93,7 @@ public class CompressorModule extends ReactContextBaseJavaModule {
|
|
|
93
93
|
|
|
94
94
|
float bitrate = options.bitrate;
|
|
95
95
|
Log.d("nomi onStart", destinationPath+"onProgress: "+bitrate);
|
|
96
|
+
<<<<<<< HEAD
|
|
96
97
|
new AudioCompressor().CompressAudio(srcPath, destinationPath, (int) bitrate*1000, new VideoSlimmer.ProgressListener() {
|
|
97
98
|
|
|
98
99
|
|
|
@@ -122,6 +123,9 @@ public class CompressorModule extends ReactContextBaseJavaModule {
|
|
|
122
123
|
sendEvent(reactContext, "videoCompressProgress", params);
|
|
123
124
|
}
|
|
124
125
|
});
|
|
126
|
+
=======
|
|
127
|
+
new AudioCompressor().CompressAudio(srcPath, destinationPath, (int) bitrate*1000);
|
|
128
|
+
>>>>>>> chore: add video compression cancel and fix stretch video
|
|
125
129
|
|
|
126
130
|
} catch (Exception ex) {
|
|
127
131
|
promise.reject(ex);
|
|
@@ -66,7 +66,7 @@ public class ImageCompressor {
|
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
|
|
69
|
-
public static String encodeImage(ByteArrayOutputStream imageDataByteArrayOutputStream, Boolean isBase64,
|
|
69
|
+
public static String encodeImage(ByteArrayOutputStream imageDataByteArrayOutputStream, Boolean isBase64,String outputExtension, ReactApplicationContext reactContext) {
|
|
70
70
|
if(isBase64)
|
|
71
71
|
{
|
|
72
72
|
byte[] imageData=imageDataByteArrayOutputStream.toByteArray();
|
|
@@ -124,16 +124,16 @@ public class ImageCompressor {
|
|
|
124
124
|
final ByteArrayOutputStream imageDataByteArrayOutputStream = ImageCompressor.compress(resizedImage, options.output, options.quality);
|
|
125
125
|
Boolean isBase64=options.returnableOutputType==ImageCompressorOptions.ReturnableOutputType.base64;
|
|
126
126
|
|
|
127
|
-
String returnableResult = ImageCompressor.encodeImage(imageDataByteArrayOutputStream,isBase64,
|
|
127
|
+
String returnableResult = ImageCompressor.encodeImage(imageDataByteArrayOutputStream,isBase64,options.output.toString(),reactContext);
|
|
128
128
|
return returnableResult;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
|
|
132
132
|
public static String autoCompressImage(String imagePath,ImageCompressorOptions compressorOptions, ReactApplicationContext reactContext) {
|
|
133
133
|
String outputExtension=compressorOptions.output.toString();
|
|
134
|
-
int quality= (int) (compressorOptions.quality*100);
|
|
135
134
|
float autoCompressMaxHeight = compressorOptions.maxHeight;
|
|
136
135
|
float autoCompressMaxWidth = compressorOptions.maxWidth;
|
|
136
|
+
Boolean isBase64=compressorOptions.returnableOutputType==ImageCompressorOptions.ReturnableOutputType.base64;
|
|
137
137
|
|
|
138
138
|
Uri uri= Uri.parse(imagePath);
|
|
139
139
|
imagePath = uri.getPath();
|
|
@@ -217,18 +217,10 @@ public class ImageCompressor {
|
|
|
217
217
|
} catch (IOException e) {
|
|
218
218
|
e.printStackTrace();
|
|
219
219
|
}
|
|
220
|
-
FileOutputStream out = null;
|
|
221
|
-
String filepath = generateCacheFilePath(outputExtension,reactContext);;
|
|
222
|
-
try {
|
|
223
|
-
out = new FileOutputStream(filepath);
|
|
224
|
-
|
|
225
|
-
//write the compressed bitmap at the destination specified by filename.
|
|
226
|
-
scaledBitmap.compress(Bitmap.CompressFormat.JPEG, quality, out);
|
|
227
220
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
return getRNFileUrl(filepath);
|
|
221
|
+
final ByteArrayOutputStream imageDataByteArrayOutputStream = ImageCompressor.compress(scaledBitmap, compressorOptions.output, compressorOptions.quality);
|
|
222
|
+
String returnableResult = ImageCompressor.encodeImage(imageDataByteArrayOutputStream,isBase64,compressorOptions.output.toString(),reactContext);
|
|
223
|
+
return returnableResult;
|
|
232
224
|
}
|
|
233
225
|
|
|
234
226
|
public static int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) {
|
|
@@ -1,15 +1,83 @@
|
|
|
1
1
|
package com.reactnativecompressor.Utils;
|
|
2
2
|
|
|
3
3
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
4
|
+
import com.facebook.react.bridge.ReactContext;
|
|
5
|
+
import com.facebook.react.bridge.WritableMap;
|
|
6
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
7
|
+
import numan.dev.videocompressor.VideoCompressTask;
|
|
8
|
+
import numan.dev.videocompressor.VideoCompressor;
|
|
4
9
|
|
|
5
10
|
import java.io.File;
|
|
6
11
|
import java.util.UUID;
|
|
7
12
|
|
|
8
13
|
public class Utils {
|
|
14
|
+
static int videoCompressionThreshold=10;
|
|
15
|
+
static Map<String, VideoCompressTask> compressorExports = new HashMap<>();
|
|
16
|
+
|
|
9
17
|
public static String generateCacheFilePath(String extension, ReactApplicationContext reactContext){
|
|
10
18
|
File outputDir = reactContext.getCacheDir();
|
|
11
19
|
|
|
12
20
|
String outputUri = String.format("%s/%s." + extension, outputDir.getPath(), UUID.randomUUID().toString());
|
|
13
21
|
return outputUri;
|
|
14
22
|
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
public static void compressVideo(String srcPath, String destinationPath, int resultWidth, int resultHeight, float videoBitRate, String uuid, Promise promise, ReactApplicationContext reactContext){
|
|
26
|
+
final int[] currentVideoCompression = {0};
|
|
27
|
+
try{
|
|
28
|
+
VideoCompressTask export=VideoCompressor.convertVideo(srcPath, destinationPath, resultWidth, resultHeight, (int) videoBitRate, new VideoCompressor.ProgressListener() {
|
|
29
|
+
@Override
|
|
30
|
+
public void onStart() {
|
|
31
|
+
//convert start
|
|
32
|
+
}
|
|
33
|
+
@Override
|
|
34
|
+
public void onFinish(boolean result) {
|
|
35
|
+
//convert finish,result(true is success,false is fail)
|
|
36
|
+
promise.resolve("file:/"+destinationPath);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Override
|
|
40
|
+
public void onError(String errorMessage) {
|
|
41
|
+
promise.reject("Compression has canncelled");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@Override
|
|
45
|
+
public void onProgress(float percent) {
|
|
46
|
+
int roundProgress=Math.round(percent);
|
|
47
|
+
if(roundProgress%videoCompressionThreshold==0&&roundProgress> currentVideoCompression[0]) {
|
|
48
|
+
WritableMap params = Arguments.createMap();
|
|
49
|
+
WritableMap data = Arguments.createMap();
|
|
50
|
+
params.putString("uuid", uuid);
|
|
51
|
+
data.putDouble("progress", percent / 100);
|
|
52
|
+
params.putMap("data", data);
|
|
53
|
+
sendEvent(reactContext, "videoCompressProgress", params);
|
|
54
|
+
currentVideoCompression[0] =roundProgress;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
compressorExports.put(uuid, export);
|
|
59
|
+
} catch (Exception ex) {
|
|
60
|
+
promise.reject(ex);
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
currentVideoCompression[0] =0;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public static void cancelCompressionHelper(String uuid){
|
|
68
|
+
try{
|
|
69
|
+
VideoCompressTask export=compressorExports.get(uuid);
|
|
70
|
+
export.cancel(true);
|
|
71
|
+
}
|
|
72
|
+
catch (Exception ex) {
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private static void sendEvent(ReactContext reactContext,
|
|
77
|
+
String eventName,
|
|
78
|
+
@Nullable WritableMap params) {
|
|
79
|
+
reactContext
|
|
80
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
81
|
+
.emit(eventName, params);
|
|
82
|
+
}
|
|
15
83
|
}
|
|
@@ -26,7 +26,8 @@ public class AutoVideoCompression {
|
|
|
26
26
|
static int currentVideoCompression=0;
|
|
27
27
|
|
|
28
28
|
public static void createCompressionSettings(String fileUrl,VideoCompressorHelper options,Promise promise, ReactApplicationContext reactContext) {
|
|
29
|
-
float maxSize = options.maxSize
|
|
29
|
+
float maxSize = options.maxSize;
|
|
30
|
+
float minimumFileSizeForCompress=options.minimumFileSizeForCompress;
|
|
30
31
|
try{
|
|
31
32
|
Uri uri= Uri.parse(fileUrl);
|
|
32
33
|
String srcPath = uri.getPath();
|
|
@@ -35,7 +36,7 @@ public class AutoVideoCompression {
|
|
|
35
36
|
File file=new File(srcPath);
|
|
36
37
|
float sizeInBytes = file.length();
|
|
37
38
|
float sizeInMb = sizeInBytes / (1024 * 1024);
|
|
38
|
-
if(sizeInMb>
|
|
39
|
+
if(sizeInMb>minimumFileSizeForCompress)
|
|
39
40
|
{
|
|
40
41
|
String destinationPath = generateCacheFilePath("mp4", reactContext);
|
|
41
42
|
int actualHeight =Integer.parseInt(metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT));
|
|
@@ -102,6 +102,7 @@ public class VideoCompressorHelper {
|
|
|
102
102
|
public float bitrate = 0;
|
|
103
103
|
public String uuid = "";
|
|
104
104
|
public float maxSize = 640.0f;
|
|
105
|
+
public float minimumFileSizeForCompress = 16.0f;
|
|
105
106
|
|
|
106
107
|
public static VideoCompressorHelper fromMap(ReadableMap map) {
|
|
107
108
|
final VideoCompressorHelper options = new VideoCompressorHelper();
|
|
@@ -120,6 +121,9 @@ public class VideoCompressorHelper {
|
|
|
120
121
|
case "uuid":
|
|
121
122
|
options.uuid = map.getString(key);
|
|
122
123
|
break;
|
|
124
|
+
case "minimumFileSizeForCompress":
|
|
125
|
+
options.minimumFileSizeForCompress =(float) map.getDouble(key);
|
|
126
|
+
break;
|
|
123
127
|
|
|
124
128
|
}
|
|
125
129
|
}
|
package/app.plugin.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./lib/commonjs/expo-plugin/compressor');
|
|
@@ -35,7 +35,7 @@ class VideoCompressor: RCTEventEmitter, URLSessionTaskDelegate {
|
|
|
35
35
|
var uploadResolvers: [String: RCTPromiseResolveBlock] = [:]
|
|
36
36
|
var uploadRejectors: [String: RCTPromiseRejectBlock] = [:]
|
|
37
37
|
let videoCompressionThreshold:Int=7
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
|
|
40
40
|
override static func requiresMainQueueSetup() -> Bool {
|
|
41
41
|
return false
|
|
@@ -199,10 +199,13 @@ func makeValidUri(filePath: String) -> String {
|
|
|
199
199
|
|
|
200
200
|
|
|
201
201
|
func compressVideo(url: URL, options: [String: Any], onProgress: @escaping (Float) -> Void, onCompletion: @escaping (URL) -> Void, onFailure: @escaping (Error) -> Void){
|
|
202
|
-
|
|
202
|
+
var minimumFileSizeForCompress:Double=16.0;
|
|
203
203
|
let fileSize=self.getfileSize(forURL: url);
|
|
204
|
-
|
|
205
|
-
|
|
204
|
+
if((options["minimumFileSizeForCompress"]) != nil)
|
|
205
|
+
{
|
|
206
|
+
minimumFileSizeForCompress=options["minimumFileSizeForCompress"] as! Double;
|
|
207
|
+
}
|
|
208
|
+
if(fileSize>minimumFileSizeForCompress)
|
|
206
209
|
{
|
|
207
210
|
if(options["compressionMethod"] as! String=="auto")
|
|
208
211
|
{
|
|
@@ -242,9 +245,9 @@ func makeValidUri(filePath: String) -> String {
|
|
|
242
245
|
let compressFactor:Float = 0.8
|
|
243
246
|
let minCompressFactor:Float = 0.8
|
|
244
247
|
let maxBitrate:Int = 1669000
|
|
245
|
-
|
|
246
|
-
var remeasuredBitrate:Int = originalBitrate /
|
|
247
|
-
remeasuredBitrate = remeasuredBitrate*
|
|
248
|
+
let minValue:Float=min(Float(originalHeight)/Float(height),Float(originalWidth)/Float(width))
|
|
249
|
+
var remeasuredBitrate:Int = Int(Float(originalBitrate) / minValue)
|
|
250
|
+
remeasuredBitrate = Int(Float(remeasuredBitrate)*compressFactor)
|
|
248
251
|
let minBitrate:Int = self.getVideoBitrateWithFactor(f: minCompressFactor) / (1280 * 720 / (width * height))
|
|
249
252
|
if (originalBitrate < minBitrate) {
|
|
250
253
|
return remeasuredBitrate;
|
|
@@ -332,7 +335,12 @@ func makeValidUri(filePath: String) -> String {
|
|
|
332
335
|
}
|
|
333
336
|
}
|
|
334
337
|
|
|
338
|
+
<<<<<<< HEAD
|
|
335
339
|
func exportVideoHelper(url: URL,asset: AVAsset, bitRate: Int,resultWidth:Float,resultHeight:Float, onProgress: @escaping (Float) -> Void, onCompletion: @escaping (URL) -> Void, onFailure: @escaping (Error) -> Void){
|
|
340
|
+
=======
|
|
341
|
+
func exportVideoHelper(url: URL,asset: AVAsset, bitRate: Int,resultWidth:Float,resultHeight:Float,uuid:String, onProgress: @escaping (Float) -> Void, onCompletion: @escaping (URL) -> Void, onFailure: @escaping (Error) -> Void){
|
|
342
|
+
var videoCompressionCounter:Int=0
|
|
343
|
+
>>>>>>> 5dc257f... fix: multiple video progress
|
|
336
344
|
var tmpURL = URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true)
|
|
337
345
|
.appendingPathComponent(ProcessInfo().globallyUniqueString)
|
|
338
346
|
.appendingPathExtension("mp4")
|
|
@@ -364,29 +372,31 @@ func makeValidUri(filePath: String) -> String {
|
|
|
364
372
|
|
|
365
373
|
exporter.export(progressHandler: { (progress) in
|
|
366
374
|
let _progress:Float=progress*100;
|
|
367
|
-
if(Int(_progress)==
|
|
375
|
+
if(Int(_progress)==videoCompressionCounter)
|
|
368
376
|
{
|
|
369
|
-
|
|
377
|
+
videoCompressionCounter=Int(_progress)+self.videoCompressionThreshold
|
|
370
378
|
onProgress(progress)
|
|
371
379
|
}
|
|
372
380
|
|
|
373
381
|
}, completionHandler: { result in
|
|
382
|
+
<<<<<<< HEAD
|
|
374
383
|
self.videoCompressionCounter=0;
|
|
375
384
|
switch result {
|
|
376
385
|
case .success(let status):
|
|
377
386
|
switch status {
|
|
387
|
+
=======
|
|
388
|
+
videoCompressionCounter=0;
|
|
389
|
+
switch exporter.status {
|
|
390
|
+
>>>>>>> 5dc257f... fix: multiple video progress
|
|
378
391
|
case .completed:
|
|
379
392
|
onCompletion(exporter.outputURL!)
|
|
380
393
|
break
|
|
381
394
|
default:
|
|
382
|
-
// let error = CompressionError(message: "Compression didn't complete")
|
|
383
|
-
// onFailure(error)
|
|
384
395
|
onCompletion(url)
|
|
385
396
|
break
|
|
386
397
|
}
|
|
387
398
|
break
|
|
388
399
|
case .failure(let error):
|
|
389
|
-
// onFailure(error)
|
|
390
400
|
onCompletion(url)
|
|
391
401
|
break
|
|
392
402
|
}
|
|
@@ -7,13 +7,13 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _utils = require("../utils");
|
|
11
11
|
|
|
12
12
|
const VideoCompressEventEmitter = new _reactNative.NativeEventEmitter(_reactNative.NativeModules.VideoCompressor);
|
|
13
13
|
const NativeVideoCompressor = _reactNative.NativeModules.VideoCompressor;
|
|
14
14
|
const Video = {
|
|
15
15
|
compress: async (fileUrl, options, onProgress) => {
|
|
16
|
-
const uuid = (0,
|
|
16
|
+
const uuid = (0, _utils.uuidv4)();
|
|
17
17
|
let subscription = null;
|
|
18
18
|
|
|
19
19
|
try {
|
|
@@ -42,6 +42,10 @@ const Video = {
|
|
|
42
42
|
modifiedOptions.maxSize = 640;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
if (options !== null && options !== void 0 && options.minimumFileSizeForCompress) {
|
|
46
|
+
modifiedOptions.minimumFileSizeForCompress = options === null || options === void 0 ? void 0 : options.minimumFileSizeForCompress;
|
|
47
|
+
}
|
|
48
|
+
|
|
45
49
|
const result = await NativeVideoCompressor.compress(fileUrl, modifiedOptions);
|
|
46
50
|
return result;
|
|
47
51
|
} finally {
|
|
@@ -51,7 +55,7 @@ const Video = {
|
|
|
51
55
|
}
|
|
52
56
|
},
|
|
53
57
|
backgroundUpload: async (url, fileUrl, options, onProgress) => {
|
|
54
|
-
const uuid = (0,
|
|
58
|
+
const uuid = (0, _utils.uuidv4)();
|
|
55
59
|
let subscription = null;
|
|
56
60
|
|
|
57
61
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":["VideoCompressEventEmitter","NativeEventEmitter","NativeModules","VideoCompressor","NativeVideoCompressor","Video","compress","fileUrl","options","onProgress","uuid","subscription","addListener","event","data","progress","modifiedOptions","bitrate","compressionMethod","maxSize","result","removeSubscription","backgroundUpload","url","written","total","Platform","OS","includes","replace","upload","method","httpMethod","headers","activateBackgroundTask","onExpired","deactivateBackgroundTask","removeAllListeners"],"mappings":";;;;;;;AAAA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["VideoCompressEventEmitter","NativeEventEmitter","NativeModules","VideoCompressor","NativeVideoCompressor","Video","compress","fileUrl","options","onProgress","uuid","subscription","addListener","event","data","progress","modifiedOptions","bitrate","compressionMethod","maxSize","minimumFileSizeForCompress","result","removeSubscription","backgroundUpload","url","written","total","Platform","OS","includes","replace","upload","method","httpMethod","headers","activateBackgroundTask","onExpired","deactivateBackgroundTask","removeAllListeners"],"mappings":";;;;;;;AAAA;;AACA;;AA8DA,MAAMA,yBAAyB,GAAG,IAAIC,+BAAJ,CAChCC,2BAAcC,eADkB,CAAlC;AAIA,MAAMC,qBAAqB,GAAGF,2BAAcC,eAA5C;AAEA,MAAME,KAA0B,GAAG;AACjCC,EAAAA,QAAQ,EAAE,OACRC,OADQ,EAERC,OAFQ,EAQRC,UARQ,KASL;AACH,UAAMC,IAAI,GAAG,oBAAb;AACA,QAAIC,YAAY,GAAG,IAAnB;;AACA,QAAI;AACF,UAAIF,UAA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BC,KAAD,IAAgB;AACduB,QAAAA,SAAS,CAACvB,KAAD,CAAT;AACAb,QAAAA,yBAAyB,CAACsB,kBAA1B,CAA6CX,YAA7C;AACD,OALkB,CAArB;AAOD;;AACD,WAAOP,qBAAqB,CAAC+B,sBAAtB,CAA6C,EAA7C,CAAP;AACD,GAlGgC;;AAmGjCE,EAAAA,wBAAwB,GAAG;AACzBrC,IAAAA,yBAAyB,CAACsC,kBAA1B,CAA6C,uBAA7C;AACA,WAAOlC,qBAAqB,CAACiC,wBAAtB,CAA+C,EAA/C,CAAP;AACD;;AAtGgC,CAAnC;eAyGehC,K","sourcesContent":["import { NativeModules, NativeEventEmitter, Platform } from 'react-native';\nimport { uuidv4 } from '../utils';\n\nexport declare enum FileSystemUploadType {\n BINARY_CONTENT = 0,\n MULTIPART = 1,\n}\n\nexport declare type FileSystemAcceptedUploadHttpMethod =\n | 'POST'\n | 'PUT'\n | 'PATCH';\nexport type compressionMethod = 'auto' | 'manual';\ntype videoCompresssionType = {\n bitrate?: number;\n maxSize?: number;\n compressionMethod?: compressionMethod;\n minimumFileSizeForCompress?: number;\n};\n\nexport declare enum FileSystemSessionType {\n BACKGROUND = 0,\n FOREGROUND = 1,\n}\n\nexport declare type HTTPResponse = {\n status: number;\n headers: Record<string, string>;\n body: string;\n};\n\nexport declare type FileSystemUploadOptions = (\n | {\n uploadType?: FileSystemUploadType.BINARY_CONTENT;\n }\n | {\n uploadType: FileSystemUploadType.MULTIPART;\n fieldName?: string;\n mimeType?: string;\n parameters?: Record<string, string>;\n }\n) & {\n headers?: Record<string, string>;\n httpMethod?: FileSystemAcceptedUploadHttpMethod;\n sessionType?: FileSystemSessionType;\n};\n\nexport type VideoCompressorType = {\n compress(\n fileUrl: string,\n options?: videoCompresssionType,\n onProgress?: (progress: number) => void\n ): Promise<string>;\n backgroundUpload(\n url: string,\n fileUrl: string,\n options: FileSystemUploadOptions,\n onProgress?: (writtem: number, total: number) => void\n ): Promise<any>;\n activateBackgroundTask(onExpired?: (data: any) => void): Promise<any>;\n deactivateBackgroundTask(): Promise<any>;\n};\n\nconst VideoCompressEventEmitter = new NativeEventEmitter(\n NativeModules.VideoCompressor\n);\n\nconst NativeVideoCompressor = NativeModules.VideoCompressor;\n\nconst Video: VideoCompressorType = {\n compress: async (\n fileUrl: string,\n options?: {\n bitrate?: number;\n compressionMethod?: compressionMethod;\n maxSize?: number;\n minimumFileSizeForCompress?: number;\n },\n onProgress?: (progress: number) => void\n ) => {\n const uuid = uuidv4();\n let subscription = null;\n try {\n if (onProgress) {\n subscription = VideoCompressEventEmitter.addListener(\n 'videoCompressProgress',\n (event: any) => {\n if (event.uuid === uuid) {\n onProgress(event.data.progress);\n }\n }\n );\n }\n const modifiedOptions: {\n uuid: string;\n bitrate?: number;\n compressionMethod?: compressionMethod;\n maxSize?: number;\n minimumFileSizeForCompress?: number;\n } = { uuid };\n if (options?.bitrate) modifiedOptions.bitrate = options?.bitrate;\n if (options?.compressionMethod) {\n modifiedOptions.compressionMethod = options?.compressionMethod;\n } else {\n modifiedOptions.compressionMethod = 'manual';\n }\n if (options?.maxSize) {\n modifiedOptions.maxSize = options?.maxSize;\n } else {\n modifiedOptions.maxSize = 640;\n }\n if (options?.minimumFileSizeForCompress) {\n modifiedOptions.minimumFileSizeForCompress =\n options?.minimumFileSizeForCompress;\n }\n const result = await NativeVideoCompressor.compress(\n fileUrl,\n modifiedOptions\n );\n return result;\n } finally {\n if (subscription) {\n VideoCompressEventEmitter.removeSubscription(subscription);\n }\n }\n },\n backgroundUpload: async (url, fileUrl, options, onProgress) => {\n const uuid = uuidv4();\n let subscription = null;\n try {\n if (onProgress) {\n subscription = VideoCompressEventEmitter.addListener(\n 'VideoCompressorProgress',\n (event: any) => {\n if (event.uuid === uuid) {\n onProgress(event.data.written, event.data.total);\n }\n }\n );\n }\n if (Platform.OS === 'android' && fileUrl.includes('file://')) {\n fileUrl = fileUrl.replace('file://', '');\n }\n const result = await NativeVideoCompressor.upload(fileUrl, {\n uuid,\n method: options.httpMethod,\n headers: options.headers,\n url,\n });\n return result;\n } finally {\n if (subscription) {\n VideoCompressEventEmitter.removeSubscription(subscription);\n }\n }\n },\n activateBackgroundTask(onExpired?) {\n if (onExpired) {\n const subscription = VideoCompressEventEmitter.addListener(\n 'backgroundTaskExpired',\n (event: any) => {\n onExpired(event);\n VideoCompressEventEmitter.removeSubscription(subscription);\n }\n );\n }\n return NativeVideoCompressor.activateBackgroundTask({});\n },\n deactivateBackgroundTask() {\n VideoCompressEventEmitter.removeAllListeners('backgroundTaskExpired');\n return NativeVideoCompressor.deactivateBackgroundTask({});\n },\n} as VideoCompressorType;\n\nexport default Video;\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _configPlugins = require("@expo/config-plugins");
|
|
9
|
+
|
|
10
|
+
const pkg = require('../../../package.json');
|
|
11
|
+
|
|
12
|
+
const withCompressor = config => config;
|
|
13
|
+
|
|
14
|
+
var _default = (0, _configPlugins.createRunOncePlugin)(withCompressor, pkg.name, pkg.version);
|
|
15
|
+
|
|
16
|
+
exports.default = _default;
|
|
17
|
+
//# sourceMappingURL=compressor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["compressor.ts"],"names":["pkg","require","withCompressor","config","name","version"],"mappings":";;;;;;;AAAA;;AACA,MAAMA,GAAG,GAAGC,OAAO,CAAC,uBAAD,CAAnB;;AAIA,MAAMC,cAAmC,GAAIC,MAAD,IAAYA,MAAxD;;eAEe,wCAAoBD,cAApB,EAAoCF,GAAG,CAACI,IAAxC,EAA8CJ,GAAG,CAACK,OAAlD,C","sourcesContent":["import { ConfigPlugin, createRunOncePlugin } from '@expo/config-plugins';\nconst pkg = require('../../../package.json');\n\ntype Props = {};\n\nconst withCompressor: ConfigPlugin<Props> = (config) => config;\n\nexport default createRunOncePlugin(withCompressor, pkg.name, pkg.version);\n"]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -33,6 +33,12 @@ Object.defineProperty(exports, "getDetails", {
|
|
|
33
33
|
return _utils.getDetails;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
+
Object.defineProperty(exports, "uuidv4", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _utils.uuidv4;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
36
42
|
exports.default = void 0;
|
|
37
43
|
|
|
38
44
|
var _Video = _interopRequireWildcard(require("./Video"));
|
|
@@ -53,7 +59,8 @@ var _default = {
|
|
|
53
59
|
Video: _Video.default,
|
|
54
60
|
Audio: _Audio.default,
|
|
55
61
|
Image: _Image.default,
|
|
56
|
-
getDetails: _utils.getDetails
|
|
62
|
+
getDetails: _utils.getDetails,
|
|
63
|
+
uuidv4: _utils.uuidv4
|
|
57
64
|
};
|
|
58
65
|
exports.default = _default;
|
|
59
66
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":["Video","Audio","Image","getDetails"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["Video","Audio","Image","getDetails","uuidv4"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;eAWe;AACbA,EAAAA,KAAK,EAALA,cADa;AAEbC,EAAAA,KAAK,EAALA,cAFa;AAGbC,EAAAA,KAAK,EAALA,cAHa;AAIbC,EAAAA,UAAU,EAAVA,iBAJa;AAKbC,EAAAA,MAAM,EAANA;AALa,C","sourcesContent":["import Video, { VideoCompressorType } from './Video';\nimport Audio from './Audio';\nimport Image from './Image';\nimport { getDetails, uuidv4 } from './utils';\n\nexport {\n Video,\n Audio,\n Image,\n //type\n VideoCompressorType,\n getDetails,\n uuidv4,\n};\nexport default {\n Video,\n Audio,\n Image,\n getDetails,\n uuidv4,\n};\n"]}
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.checkUrlAndOptions = exports.getDetails = exports.DEFAULT_COMPRESS_AUDIO_OPTIONS = exports.AUDIO_BITRATE = void 0;
|
|
6
|
+
exports.uuidv4 = exports.checkUrlAndOptions = exports.getDetails = exports.DEFAULT_COMPRESS_AUDIO_OPTIONS = exports.AUDIO_BITRATE = void 0;
|
|
7
7
|
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
|
|
10
|
+
/* eslint-disable no-bitwise */
|
|
10
11
|
const {
|
|
11
12
|
Compressor
|
|
12
13
|
} = _reactNative.NativeModules;
|
|
@@ -136,4 +137,15 @@ const checkUrlAndOptions = async (url, options) => {
|
|
|
136
137
|
};
|
|
137
138
|
|
|
138
139
|
exports.checkUrlAndOptions = checkUrlAndOptions;
|
|
140
|
+
|
|
141
|
+
const uuidv4 = () => {
|
|
142
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
143
|
+
const r = parseFloat('0.' + Math.random().toString().replace('0.', '') + new Date().getTime()) * 16 | 0,
|
|
144
|
+
// eslint-disable-next-line eqeqeq
|
|
145
|
+
v = c == 'x' ? r : r & 0x3 | 0x8;
|
|
146
|
+
return v.toString(16);
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
exports.uuidv4 = uuidv4;
|
|
139
151
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":["Compressor","NativeModules","AUDIO_BITRATE","INCORRECT_INPUT_PATH","INCORRECT_OUTPUT_PATH","ERROR_OCCUR_WHILE_GENERATING_OUTPUT_FILE","DEFAULT_COMPRESS_AUDIO_OPTIONS","bitrate","quality","outputFilePath","generateFile","extension","Promise","resolve","reject","then","result","catch","error","isValidUrl","url","test","getFullFilename","path","_path","includes","length","substring","array","split","isFileNameError","filename","getFilename","fullFilename","slice","join","isRemoteMedia","getDetails","mediaFullPath","extesnion","Error","mediaInfo","JSON","parse","mediaInformation","getMediaProperties","bit_rate","size","Number","format","e","checkUrlAndOptions","options","defaultResult","isCorrect","message","undefined"],"mappings":";;;;;;;AAAA;;AACA,MAAM;AAAEA,EAAAA;AAAF,IAAiBC,0BAAvB;AACO,MAAMC,aAAa,GAAG,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,EAAgB,GAAhB,EAAqB,EAArB,EAAyB,EAAzB,EAA6B,EAA7B,CAAtB;;AAEP,MAAMC,oBAAoB,GAAG,kDAA7B;AACA,MAAMC,qBAAqB,GACzB,mDADF;AAEA,MAAMC,wCAAwC,GAC5C,6CADF;AAcO,MAAMC,8BAAqD,GAAG;AACnEC,EAAAA,OAAO,EAAE,EAD0D;AAEnEC,EAAAA,OAAO,EAAE,QAF0D;AAGnEC,EAAAA,cAAc,EAAE;AAHmD,CAA9D;;;AAUP,MAAMC,YAAiB,GAAIC,SAAD,IAAuB;AAC/C,SAAO,IAAIC,OAAJ,CAAY,CAACC,OAAD,EAAUC,MAAV,KAAqB;AACtCd,IAAAA,UAAU,CAACU,YAAX,CAAwBC,SAAxB,EACGI,IADH,CACSC,MAAD,IAAiBH,OAAO,CAAC,YAAYG,MAAb,CADhC,EAEGC,KAFH,CAEUC,KAAD,IAAgBJ,MAAM,CAACI,KAAD,CAF/B;AAGD,GAJM,CAAP;AAKD,CAND;;AAQA,MAAMC,UAAU,GAAIC,GAAD,IACjB,wDAAwDC,IAAxD,CAA6DD,GAA7D,CADF;;AAGA,MAAME,eAAe,GAAIC,IAAD,IAAyB;AAC/C,MAAI,OAAOA,IAAP,KAAgB,QAApB,EAA8B;AAC5B,QAAIC,KAAK,GAAGD,IAAZ,CAD4B,CAG5B;;AACA,QAAIA,IAAI,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IAF4B;AAGvCC,IAAAA,OAAO,EAAE;AAH8B,GAAzC,CAN+B,CAY/B;;AACA,MAAI9C,cAAJ;;AACA,MAAI;AACF;AACA;AACA,QAAI2C,OAAO,CAAC3C,cAAZ,EAA4B;AAC1BA,MAAAA,cAAc,GAAG2C,OAAO,CAAC3C,cAAzB;AACA4C,MAAAA,aAAa,CAAC5C,cAAd,GAA+BA,cAA/B;AACD,KAHD,MAGO;AACLA,MAAAA,cAAc,GAAG,MAAMC,YAAY,CAAC,KAAD,CAAnC;AACA2C,MAAAA,aAAa,CAAC5C,cAAd,GAA+BA,cAA/B;AACD;;AACD,QAAIA,cAAc,KAAK+C,SAAnB,IAAgC/C,cAAc,KAAK,IAAvD,EAA6D;AAC3D4C,MAAAA,aAAa,CAACC,SAAd,GAA0B,KAA1B;AACAD,MAAAA,aAAa,CAACE,OAAd,GAAwBH,OAAO,CAAC3C,cAAR,GACpBL,qBADoB,GAEpBC,wCAFJ;AAGD;AACF,GAhBD,CAgBE,OAAO6C,CAAP,EAAU;AACVG,IAAAA,aAAa,CAACC,SAAd,GAA0B,KAA1B;AACAD,IAAAA,aAAa,CAACE,OAAd,GAAwBH,OAAO,CAAC3C,cAAR,GACpBL,qBADoB,GAEpBC,wCAFJ;AAGD,GArBD,SAqBU;AACR,WAAOgD,aAAP;AACD;AACF,CAzCM","sourcesContent":["import { NativeModules } from 'react-native';\nconst { Compressor } = NativeModules;\nexport const AUDIO_BITRATE = [256, 192, 160, 128, 96, 64, 32];\ntype qualityType = 'low' | 'medium' | 'high';\nconst INCORRECT_INPUT_PATH = 'Incorrect input path. Please provide a valid one';\nconst INCORRECT_OUTPUT_PATH =\n 'Incorrect output path. Please provide a valid one';\nconst ERROR_OCCUR_WHILE_GENERATING_OUTPUT_FILE =\n 'An error occur while generating output file';\ntype audioCompresssionType = {\n bitrate?: number;\n quality: qualityType;\n outputFilePath?: string | undefined | null;\n};\n\nexport type defaultResultType = {\n outputFilePath: string | undefined | null;\n isCorrect: boolean;\n message: string;\n};\n\nexport const DEFAULT_COMPRESS_AUDIO_OPTIONS: audioCompresssionType = {\n bitrate: 96,\n quality: 'medium',\n outputFilePath: '',\n};\n\nexport type AudioType = {\n compress(value: string, options?: audioCompresssionType): Promise<string>;\n};\n\nconst generateFile: any = (extension: string) => {\n return new Promise((resolve, reject) => {\n Compressor.generateFile(extension)\n .then((result: any) => resolve('file://' + result))\n .catch((error: any) => reject(error));\n });\n};\n\nconst isValidUrl = (url: string) =>\n /^(?:\\w+:)?\\/\\/([^\\s\\.]+\\.\\S{2}|localhost[\\:?\\d]*)\\S*$/.test(url);\n\nconst getFullFilename = (path: string | null) => {\n if (typeof path === 'string') {\n let _path = path;\n\n // In case of remote media, check if the url would be valid one\n if (path.includes('http') && !isValidUrl(path)) {\n return INCORRECT_INPUT_PATH;\n }\n\n // In case of url, check if it ends with \"/\" and do not consider it furthermore\n if (_path[_path.length - 1] === '/')\n _path = _path.substring(0, path.length - 1);\n\n const array = _path.split('/');\n return array.length > 1 ? array[array.length - 1] : INCORRECT_INPUT_PATH;\n }\n return INCORRECT_INPUT_PATH;\n};\n\nconst isFileNameError = (filename: string) => {\n return filename === INCORRECT_INPUT_PATH;\n};\n\nconst getFilename = (path: string | null) => {\n const fullFilename = getFullFilename(path);\n if (!isFileNameError(fullFilename)) {\n const array = fullFilename.split('.');\n return array.length > 1 ? array.slice(0, -1).join('') : array.join('');\n }\n return fullFilename;\n};\n\nconst isRemoteMedia = (path: string | null) => {\n return typeof path === 'string' ? path.split(':/')[0].includes('http') : null;\n};\n\nexport const getDetails = (\n mediaFullPath: string,\n extesnion: 'mp3' | 'mp4' = 'mp3'\n): Promise<any | null> => {\n return new Promise(async (resolve, reject) => {\n try {\n // Since we used \"-v error\", a work around is to call first this command before the following\n const result: any = {};\n if (result !== 0) {\n throw new Error('Failed to execute command');\n }\n\n // get the output result of the command\n // example of output {\"programs\": [], \"streams\": [{\"width\": 640,\"height\": 360}], \"format\": {\"size\": \"15804433\"}}\n let mediaInfo: any = await {};\n mediaInfo = JSON.parse(mediaInfo);\n\n // execute second command\n const mediaInformation: any = await {};\n\n // treat both results\n mediaInformation.filename = getFilename(mediaFullPath);\n mediaInformation.bitrate = mediaInformation.getMediaProperties().bit_rate;\n mediaInformation.extension = extesnion;\n mediaInformation.isRemoteMedia = isRemoteMedia(mediaFullPath);\n mediaInformation.size = Number(mediaInfo.format.size);\n\n resolve(mediaInformation);\n } catch (e) {\n reject(e);\n }\n });\n};\n\nexport const checkUrlAndOptions = async (\n url: string,\n options: audioCompresssionType\n): Promise<defaultResultType> => {\n if (!url) {\n throw new Error(\n 'Compression url is empty, please provide a url for compression.'\n );\n }\n const defaultResult: defaultResultType = {\n outputFilePath: '',\n isCorrect: true,\n message: '',\n };\n\n // Check if output file is correct\n let outputFilePath: string | undefined | null;\n try {\n // use default output file\n // or use new file from cache folder\n if (options.outputFilePath) {\n outputFilePath = options.outputFilePath;\n defaultResult.outputFilePath = outputFilePath;\n } else {\n outputFilePath = await generateFile('mp3');\n defaultResult.outputFilePath = outputFilePath;\n }\n if (outputFilePath === undefined || outputFilePath === null) {\n defaultResult.isCorrect = false;\n defaultResult.message = options.outputFilePath\n ? INCORRECT_OUTPUT_PATH\n : ERROR_OCCUR_WHILE_GENERATING_OUTPUT_FILE;\n }\n } catch (e) {\n defaultResult.isCorrect = false;\n defaultResult.message = options.outputFilePath\n ? INCORRECT_OUTPUT_PATH\n : ERROR_OCCUR_WHILE_GENERATING_OUTPUT_FILE;\n } finally {\n return defaultResult;\n }\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["Compressor","NativeModules","AUDIO_BITRATE","INCORRECT_INPUT_PATH","INCORRECT_OUTPUT_PATH","ERROR_OCCUR_WHILE_GENERATING_OUTPUT_FILE","DEFAULT_COMPRESS_AUDIO_OPTIONS","bitrate","quality","outputFilePath","generateFile","extension","Promise","resolve","reject","then","result","catch","error","isValidUrl","url","test","getFullFilename","path","_path","includes","length","substring","array","split","isFileNameError","filename","getFilename","fullFilename","slice","join","isRemoteMedia","getDetails","mediaFullPath","extesnion","Error","mediaInfo","JSON","parse","mediaInformation","getMediaProperties","bit_rate","size","Number","format","e","checkUrlAndOptions","options","defaultResult","isCorrect","message","undefined","uuidv4","replace","c","r","parseFloat","Math","random","toString","Date","getTime","v"],"mappings":";;;;;;;AACA;;AADA;AAEA,MAAM;AAAEA,EAAAA;AAAF,IAAiBC,0BAAvB;AACO,MAAMC,aAAa,GAAG,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,EAAgB,GAAhB,EAAqB,EAArB,EAAyB,EAAzB,EAA6B,EAA7B,CAAtB;;AAEP,MAAMC,oBAAoB,GAAG,kDAA7B;AACA,MAAMC,qBAAqB,GACzB,mDADF;AAEA,MAAMC,wCAAwC,GAC5C,6CADF;AAcO,MAAMC,8BAAqD,GAAG;AACnEC,EAAAA,OAAO,EAAE,EAD0D;AAEnEC,EAAAA,OAAO,EAAE,QAF0D;AAGnEC,EAAAA,cAAc,EAAE;AAHmD,CAA9D;;;AAUP,MAAMC,YAAiB,GAAIC,SAAD,IAAuB;AAC/C,SAAO,IAAIC,OAAJ,CAAY,CAACC,OAAD,EAAUC,MAAV,KAAqB;AACtCd,IAAAA,UAAU,CAACU,YAAX,CAAwBC,SAAxB,EACGI,IADH,CACSC,MAAD,IAAiBH,OAAO,CAAC,YAAYG,MAAb,CADhC,EAEGC,KAFH,CAEUC,KAAD,IAAgBJ,MAAM,CAACI,KAAD,CAF/B;AAGD,GAJM,CAAP;AAKD,CAND;;AAQA,MAAMC,UAAU,GAAIC,GAAD,IACjB,wDAAwDC,IAAxD,CAA6DD,GAA7D,CADF;;AAGA,MAAME,eAAe,GAAIC,IAAD,IAAyB;AAC/C,MAAI,OAAOA,IAAP,KAAgB,QAApB,EAA8B;AAC5B,QAAIC,KAAK,GAAGD,IAAZ,CAD4B,CAG5B;;AACA,QAAIA,IAAI,CAACE,QAAL,CAAc,MAAd,KAAyB,CAACN,UAAU,CAACI,IAA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AAP;AACD,GAZM,CAAP;AAaD,CAdM","sourcesContent":["/* eslint-disable no-bitwise */\nimport { NativeModules } from 'react-native';\nconst { Compressor } = NativeModules;\nexport const AUDIO_BITRATE = [256, 192, 160, 128, 96, 64, 32];\ntype qualityType = 'low' | 'medium' | 'high';\nconst INCORRECT_INPUT_PATH = 'Incorrect input path. Please provide a valid one';\nconst INCORRECT_OUTPUT_PATH =\n 'Incorrect output path. Please provide a valid one';\nconst ERROR_OCCUR_WHILE_GENERATING_OUTPUT_FILE =\n 'An error occur while generating output file';\ntype audioCompresssionType = {\n bitrate?: number;\n quality: qualityType;\n outputFilePath?: string | undefined | null;\n};\n\nexport type defaultResultType = {\n outputFilePath: string | undefined | null;\n isCorrect: boolean;\n message: string;\n};\n\nexport const DEFAULT_COMPRESS_AUDIO_OPTIONS: audioCompresssionType = {\n bitrate: 96,\n quality: 'medium',\n outputFilePath: '',\n};\n\nexport type AudioType = {\n compress(value: string, options?: audioCompresssionType): Promise<string>;\n};\n\nconst generateFile: any = (extension: string) => {\n return new Promise((resolve, reject) => {\n Compressor.generateFile(extension)\n .then((result: any) => resolve('file://' + result))\n .catch((error: any) => reject(error));\n });\n};\n\nconst isValidUrl = (url: string) =>\n /^(?:\\w+:)?\\/\\/([^\\s\\.]+\\.\\S{2}|localhost[\\:?\\d]*)\\S*$/.test(url);\n\nconst getFullFilename = (path: string | null) => {\n if (typeof path === 'string') {\n let _path = path;\n\n // In case of remote media, check if the url would be valid one\n if (path.includes('http') && !isValidUrl(path)) {\n return INCORRECT_INPUT_PATH;\n }\n\n // In case of url, check if it ends with \"/\" and do not consider it furthermore\n if (_path[_path.length - 1] === '/')\n _path = _path.substring(0, path.length - 1);\n\n const array = _path.split('/');\n return array.length > 1 ? array[array.length - 1] : INCORRECT_INPUT_PATH;\n }\n return INCORRECT_INPUT_PATH;\n};\n\nconst isFileNameError = (filename: string) => {\n return filename === INCORRECT_INPUT_PATH;\n};\n\nconst getFilename = (path: string | null) => {\n const fullFilename = getFullFilename(path);\n if (!isFileNameError(fullFilename)) {\n const array = fullFilename.split('.');\n return array.length > 1 ? array.slice(0, -1).join('') : array.join('');\n }\n return fullFilename;\n};\n\nconst isRemoteMedia = (path: string | null) => {\n return typeof path === 'string' ? path.split(':/')[0].includes('http') : null;\n};\n\nexport const getDetails = (\n mediaFullPath: string,\n extesnion: 'mp3' | 'mp4' = 'mp3'\n): Promise<any | null> => {\n return new Promise(async (resolve, reject) => {\n try {\n // Since we used \"-v error\", a work around is to call first this command before the following\n const result: any = {};\n if (result !== 0) {\n throw new Error('Failed to execute command');\n }\n\n // get the output result of the command\n // example of output {\"programs\": [], \"streams\": [{\"width\": 640,\"height\": 360}], \"format\": {\"size\": \"15804433\"}}\n let mediaInfo: any = await {};\n mediaInfo = JSON.parse(mediaInfo);\n\n // execute second command\n const mediaInformation: any = await {};\n\n // treat both results\n mediaInformation.filename = getFilename(mediaFullPath);\n mediaInformation.bitrate = mediaInformation.getMediaProperties().bit_rate;\n mediaInformation.extension = extesnion;\n mediaInformation.isRemoteMedia = isRemoteMedia(mediaFullPath);\n mediaInformation.size = Number(mediaInfo.format.size);\n\n resolve(mediaInformation);\n } catch (e) {\n reject(e);\n }\n });\n};\n\nexport const checkUrlAndOptions = async (\n url: string,\n options: audioCompresssionType\n): Promise<defaultResultType> => {\n if (!url) {\n throw new Error(\n 'Compression url is empty, please provide a url for compression.'\n );\n }\n const defaultResult: defaultResultType = {\n outputFilePath: '',\n isCorrect: true,\n message: '',\n };\n\n // Check if output file is correct\n let outputFilePath: string | undefined | null;\n try {\n // use default output file\n // or use new file from cache folder\n if (options.outputFilePath) {\n outputFilePath = options.outputFilePath;\n defaultResult.outputFilePath = outputFilePath;\n } else {\n outputFilePath = await generateFile('mp3');\n defaultResult.outputFilePath = outputFilePath;\n }\n if (outputFilePath === undefined || outputFilePath === null) {\n defaultResult.isCorrect = false;\n defaultResult.message = options.outputFilePath\n ? INCORRECT_OUTPUT_PATH\n : ERROR_OCCUR_WHILE_GENERATING_OUTPUT_FILE;\n }\n } catch (e) {\n defaultResult.isCorrect = false;\n defaultResult.message = options.outputFilePath\n ? INCORRECT_OUTPUT_PATH\n : ERROR_OCCUR_WHILE_GENERATING_OUTPUT_FILE;\n } finally {\n return defaultResult;\n }\n};\n\nexport const uuidv4 = () => {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {\n const r =\n (parseFloat(\n '0.' +\n Math.random().toString().replace('0.', '') +\n new Date().getTime()\n ) *\n 16) |\n 0,\n // eslint-disable-next-line eqeqeq\n v = c == 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NativeModules, NativeEventEmitter, Platform } from 'react-native';
|
|
2
|
-
import {
|
|
2
|
+
import { uuidv4 } from '../utils';
|
|
3
3
|
const VideoCompressEventEmitter = new NativeEventEmitter(NativeModules.VideoCompressor);
|
|
4
4
|
const NativeVideoCompressor = NativeModules.VideoCompressor;
|
|
5
5
|
const Video = {
|
|
@@ -33,6 +33,10 @@ const Video = {
|
|
|
33
33
|
modifiedOptions.maxSize = 640;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
if (options !== null && options !== void 0 && options.minimumFileSizeForCompress) {
|
|
37
|
+
modifiedOptions.minimumFileSizeForCompress = options === null || options === void 0 ? void 0 : options.minimumFileSizeForCompress;
|
|
38
|
+
}
|
|
39
|
+
|
|
36
40
|
const result = await NativeVideoCompressor.compress(fileUrl, modifiedOptions);
|
|
37
41
|
return result;
|
|
38
42
|
} finally {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":["NativeModules","NativeEventEmitter","Platform","
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["NativeModules","NativeEventEmitter","Platform","uuidv4","VideoCompressEventEmitter","VideoCompressor","NativeVideoCompressor","Video","compress","fileUrl","options","onProgress","uuid","subscription","addListener","event","data","progress","modifiedOptions","bitrate","compressionMethod","maxSize","minimumFileSizeForCompress","result","removeSubscription","backgroundUpload","url","written","total","OS","includes","replace","upload","method","httpMethod","headers","activateBackgroundTask","onExpired","deactivateBackgroundTask","removeAllListeners"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,kBAAxB,EAA4CC,QAA5C,QAA4D,cAA5D;AACA,SAASC,MAAT,QAAuB,UAAvB;AA8DA,MAAMC,yBAAyB,GAAG,IAAIH,kBAAJ,CAChCD,aAAa,CAACK,eADkB,CAAlC;AAIA,MAAMC,qBAAqB,GAAGN,aAAa,CAACK,eAA5C;AAEA,MAAME,KAA0B,GAAG;AACjCC,EAAAA,QAAQ,EAAE,OACRC,OADQ,EAERC,OAFQ,EAQRC,UARQ,KASL;AACH,UAAMC,IAAI,GAAGT,MAAM,EAAnB;AACA,QAAIU,YAAY,GAAG,IAAnB;;AACA,QAAI;AACF,UAAIF,UAAJ,EAAgB;AACdE,QAAAA,YAAY,GAAGT,yBAAyB,CAACU,WAA1B,CACb,uBADa,EAEZC,KAAD,IAAgB;AACd,cAAIA,KAAK,CAACH,IAAN,KAAeA,IAAnB,EAAyB;AACvBD,YAAAA,UAAU,CAACI,KAAK,CAACC,IAAN,CAAWC,QAAZ,CAAV;AACD;AACF,SANY,CAAf;AAQD;;AACD,YAAMC,eAML,GAAG;AAAEN,QAAAA;AAAF,OANJ;AAOA,UAAIF,OAAJ,aAAIA,OAAJ,eAAIA,OAAO,CAAES,OAAb,EAAsBD,eAAe,CAACC,OAAhB,GAA0BT,OAA1B,aAA0BA,OAA1B,uBAA0BA,OAAO,CAAES,OAAnC;;AACtB,UAAIT,OAAJ,aAAIA,OAAJ,eAAIA,OAAO,CAAEU,iBAAb,EAAgC;AAC9BF,QAAAA,eAAe,CAACE,iBAAhB,GAAoCV,OAApC,aAAoCA,OAApC,uBAAoCA,OAAO,CAAEU,iBAA7C;AACD,OAFD,MAEO;AACLF,QAAAA,eAAe,CAACE,iBAAhB,GAAoC,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,OAAO,GAAGA,OAAO,CAACsB,OAAR,CAAgB,SAAhB,EAA2B,EAA3B,CAAV;AACD;;AACD,YAAMR,MAAM,GAAG,MAAMjB,qBAAqB,CAAC0B,MAAtB,CAA6BvB,OAA7B,EAAsC;AACzDG,QAAAA,IADyD;AAEzDqB,QAAAA,MAAM,EAAEvB,OAAO,CAACwB,UAFyC;AAGzDC,QAAAA,OAAO,EAAEzB,OAAO,CAACyB,OAHwC;AAIzDT,QAAAA;AAJyD,OAAtC,CAArB;AAMA,aAAOH,MAAP;AACD,KArBD,SAqBU;AACR,UAAIV,YAAJ,EAAkB;AAChBT,QAAAA,yBAAyB,CAACoB,kBAA1B,CAA6CX,YAA7C;AACD;AACF;AACF,GAtFgC;;AAuFjCuB,EAAAA,sBAAsB,CAACC,SAAD,EAAa;AACjC,QAAIA,SAAJ,EAAe;AACb,YAAMxB,YAAY,GAAGT,yBAAyB,CAACU,WAA1B,CACnB,uBADmB,EAElBC,KAAD,IAAgB;AACdsB,QAAAA,SAAS,CAACtB,KAAD,CAAT;AACAX,QAAAA,yBAAyB,CAACoB,kBAA1B,CAA6CX,YAA7C;AACD,OALkB,CAArB;AAOD;;AACD,WAAOP,qBAAqB,CAAC8B,sBAAtB,CAA6C,EAA7C,CAAP;AACD,GAlGgC;;AAmGjCE,EAAAA,wBAAwB,GAAG;AACzBlC,IAAAA,yBAAyB,CAACmC,kBAA1B,CAA6C,uBAA7C;AACA,WAAOjC,qBAAqB,CAACgC,wBAAtB,CAA+C,EAA/C,CAAP;AACD;;AAtGgC,CAAnC;AAyGA,eAAe/B,KAAf","sourcesContent":["import { NativeModules, NativeEventEmitter, Platform } from 'react-native';\nimport { uuidv4 } from '../utils';\n\nexport declare enum FileSystemUploadType {\n BINARY_CONTENT = 0,\n MULTIPART = 1,\n}\n\nexport declare type FileSystemAcceptedUploadHttpMethod =\n | 'POST'\n | 'PUT'\n | 'PATCH';\nexport type compressionMethod = 'auto' | 'manual';\ntype videoCompresssionType = {\n bitrate?: number;\n maxSize?: number;\n compressionMethod?: compressionMethod;\n minimumFileSizeForCompress?: number;\n};\n\nexport declare enum FileSystemSessionType {\n BACKGROUND = 0,\n FOREGROUND = 1,\n}\n\nexport declare type HTTPResponse = {\n status: number;\n headers: Record<string, string>;\n body: string;\n};\n\nexport declare type FileSystemUploadOptions = (\n | {\n uploadType?: FileSystemUploadType.BINARY_CONTENT;\n }\n | {\n uploadType: FileSystemUploadType.MULTIPART;\n fieldName?: string;\n mimeType?: string;\n parameters?: Record<string, string>;\n }\n) & {\n headers?: Record<string, string>;\n httpMethod?: FileSystemAcceptedUploadHttpMethod;\n sessionType?: FileSystemSessionType;\n};\n\nexport type VideoCompressorType = {\n compress(\n fileUrl: string,\n options?: videoCompresssionType,\n onProgress?: (progress: number) => void\n ): Promise<string>;\n backgroundUpload(\n url: string,\n fileUrl: string,\n options: FileSystemUploadOptions,\n onProgress?: (writtem: number, total: number) => void\n ): Promise<any>;\n activateBackgroundTask(onExpired?: (data: any) => void): Promise<any>;\n deactivateBackgroundTask(): Promise<any>;\n};\n\nconst VideoCompressEventEmitter = new NativeEventEmitter(\n NativeModules.VideoCompressor\n);\n\nconst NativeVideoCompressor = NativeModules.VideoCompressor;\n\nconst Video: VideoCompressorType = {\n compress: async (\n fileUrl: string,\n options?: {\n bitrate?: number;\n compressionMethod?: compressionMethod;\n maxSize?: number;\n minimumFileSizeForCompress?: number;\n },\n onProgress?: (progress: number) => void\n ) => {\n const uuid = uuidv4();\n let subscription = null;\n try {\n if (onProgress) {\n subscription = VideoCompressEventEmitter.addListener(\n 'videoCompressProgress',\n (event: any) => {\n if (event.uuid === uuid) {\n onProgress(event.data.progress);\n }\n }\n );\n }\n const modifiedOptions: {\n uuid: string;\n bitrate?: number;\n compressionMethod?: compressionMethod;\n maxSize?: number;\n minimumFileSizeForCompress?: number;\n } = { uuid };\n if (options?.bitrate) modifiedOptions.bitrate = options?.bitrate;\n if (options?.compressionMethod) {\n modifiedOptions.compressionMethod = options?.compressionMethod;\n } else {\n modifiedOptions.compressionMethod = 'manual';\n }\n if (options?.maxSize) {\n modifiedOptions.maxSize = options?.maxSize;\n } else {\n modifiedOptions.maxSize = 640;\n }\n if (options?.minimumFileSizeForCompress) {\n modifiedOptions.minimumFileSizeForCompress =\n options?.minimumFileSizeForCompress;\n }\n const result = await NativeVideoCompressor.compress(\n fileUrl,\n modifiedOptions\n );\n return result;\n } finally {\n if (subscription) {\n VideoCompressEventEmitter.removeSubscription(subscription);\n }\n }\n },\n backgroundUpload: async (url, fileUrl, options, onProgress) => {\n const uuid = uuidv4();\n let subscription = null;\n try {\n if (onProgress) {\n subscription = VideoCompressEventEmitter.addListener(\n 'VideoCompressorProgress',\n (event: any) => {\n if (event.uuid === uuid) {\n onProgress(event.data.written, event.data.total);\n }\n }\n );\n }\n if (Platform.OS === 'android' && fileUrl.includes('file://')) {\n fileUrl = fileUrl.replace('file://', '');\n }\n const result = await NativeVideoCompressor.upload(fileUrl, {\n uuid,\n method: options.httpMethod,\n headers: options.headers,\n url,\n });\n return result;\n } finally {\n if (subscription) {\n VideoCompressEventEmitter.removeSubscription(subscription);\n }\n }\n },\n activateBackgroundTask(onExpired?) {\n if (onExpired) {\n const subscription = VideoCompressEventEmitter.addListener(\n 'backgroundTaskExpired',\n (event: any) => {\n onExpired(event);\n VideoCompressEventEmitter.removeSubscription(subscription);\n }\n );\n }\n return NativeVideoCompressor.activateBackgroundTask({});\n },\n deactivateBackgroundTask() {\n VideoCompressEventEmitter.removeAllListeners('backgroundTaskExpired');\n return NativeVideoCompressor.deactivateBackgroundTask({});\n },\n} as VideoCompressorType;\n\nexport default Video;\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createRunOncePlugin } from '@expo/config-plugins';
|
|
2
|
+
|
|
3
|
+
const pkg = require('../../../package.json');
|
|
4
|
+
|
|
5
|
+
const withCompressor = config => config;
|
|
6
|
+
|
|
7
|
+
export default createRunOncePlugin(withCompressor, pkg.name, pkg.version);
|
|
8
|
+
//# sourceMappingURL=compressor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["compressor.ts"],"names":["createRunOncePlugin","pkg","require","withCompressor","config","name","version"],"mappings":"AAAA,SAAuBA,mBAAvB,QAAkD,sBAAlD;;AACA,MAAMC,GAAG,GAAGC,OAAO,CAAC,uBAAD,CAAnB;;AAIA,MAAMC,cAAmC,GAAIC,MAAD,IAAYA,MAAxD;;AAEA,eAAeJ,mBAAmB,CAACG,cAAD,EAAiBF,GAAG,CAACI,IAArB,EAA2BJ,GAAG,CAACK,OAA/B,CAAlC","sourcesContent":["import { ConfigPlugin, createRunOncePlugin } from '@expo/config-plugins';\nconst pkg = require('../../../package.json');\n\ntype Props = {};\n\nconst withCompressor: ConfigPlugin<Props> = (config) => config;\n\nexport default createRunOncePlugin(withCompressor, pkg.name, pkg.version);\n"]}
|
package/lib/module/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import Video, { VideoCompressorType } from './Video';
|
|
2
2
|
import Audio from './Audio';
|
|
3
3
|
import Image from './Image';
|
|
4
|
-
import { getDetails } from './utils';
|
|
4
|
+
import { getDetails, uuidv4 } from './utils';
|
|
5
5
|
export { Video, Audio, Image //type
|
|
6
|
-
, VideoCompressorType, getDetails };
|
|
6
|
+
, VideoCompressorType, getDetails, uuidv4 };
|
|
7
7
|
export default {
|
|
8
8
|
Video,
|
|
9
9
|
Audio,
|
|
10
10
|
Image,
|
|
11
|
-
getDetails
|
|
11
|
+
getDetails,
|
|
12
|
+
uuidv4
|
|
12
13
|
};
|
|
13
14
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":["Video","VideoCompressorType","Audio","Image","getDetails"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,mBAAhB,QAA2C,SAA3C;AACA,OAAOC,KAAP,MAAkB,SAAlB;AACA,OAAOC,KAAP,MAAkB,SAAlB;AACA,SAASC,UAAT,
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["Video","VideoCompressorType","Audio","Image","getDetails","uuidv4"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,mBAAhB,QAA2C,SAA3C;AACA,OAAOC,KAAP,MAAkB,SAAlB;AACA,OAAOC,KAAP,MAAkB,SAAlB;AACA,SAASC,UAAT,EAAqBC,MAArB,QAAmC,SAAnC;AAEA,SACEL,KADF,EAEEE,KAFF,EAGEC,KAHF,CAIE;AAJF,EAKEF,mBALF,EAMEG,UANF,EAOEC,MAPF;AASA,eAAe;AACbL,EAAAA,KADa;AAEbE,EAAAA,KAFa;AAGbC,EAAAA,KAHa;AAIbC,EAAAA,UAJa;AAKbC,EAAAA;AALa,CAAf","sourcesContent":["import Video, { VideoCompressorType } from './Video';\nimport Audio from './Audio';\nimport Image from './Image';\nimport { getDetails, uuidv4 } from './utils';\n\nexport {\n Video,\n Audio,\n Image,\n //type\n VideoCompressorType,\n getDetails,\n uuidv4,\n};\nexport default {\n Video,\n Audio,\n Image,\n getDetails,\n uuidv4,\n};\n"]}
|