react-native-video-trim 1.0.6 → 1.0.8

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 CHANGED
@@ -147,9 +147,9 @@ Main method to show Video Editor UI.
147
147
 
148
148
  - `saveToPhoto` (optional, `default = true`): whether to save video to photo/gallery after editing
149
149
  - `maxDuration` (optional): maximum duration for the trimmed video
150
- - `leftButtonText` (optional): text for left button in Editor dialog
151
- - `rightButtonText` (optional): text for right button in Editor dialog
152
- - `title` (optional, iOS only): title Editor dialog
150
+ - `cancelButtonText` (optional): text of left button in Editor dialog
151
+ - `saveButtonText` (optional): text of right button in Editor dialog
152
+ - `title` (optional, iOS only): title of Editor dialog
153
153
 
154
154
  If `saveToPhoto = true`, you must ensure that you have request permission to write to photo/gallery
155
155
  - For Android: you need to have `<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />` in AndroidManifest.xml
@@ -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) {
@@ -493,14 +493,14 @@ public class VideoTrimmerView extends FrameLayout implements IVideoTrimmerView {
493
493
  this.mMaxDuration = config.getInt("maxDuration");
494
494
  }
495
495
 
496
- if (config.hasKey("leftButtonText")) {
496
+ if (config.hasKey("cancelButtonText")) {
497
497
  TextView tv = findViewById(R.id.cancelBtn);
498
- tv.setText(config.getString("leftButtonText"));
498
+ tv.setText(config.getString("cancelButtonText"));
499
499
  }
500
500
 
501
- if (config.hasKey("rightButtonText")) {
501
+ if (config.hasKey("saveButtonText")) {
502
502
  TextView tv = findViewById(R.id.saveBtn);
503
- tv.setText(config.getString("rightButtonText"));
503
+ tv.setText(config.getString("saveButtonText"));
504
504
  }
505
505
  }
506
506
  }
@@ -74,12 +74,12 @@ class VideoTrim: RCTEventEmitter, UIVideoEditorControllerDelegate, UINavigationC
74
74
  // when it comes to bar button customization
75
75
  // we can't customize text of original buttons here, we can only set attrs like enabled/hidden
76
76
  // to customize text we need to create new button
77
- if let leftBtnText = config["leftButtonText"] as? String, !leftBtnText.isEmpty {
78
- topItem.leftBarButtonItem = UIBarButtonItem(title: leftBtnText, style: topItem.leftBarButtonItem?.style ?? .plain, target: topItem.leftBarButtonItem?.target, action: topItem.leftBarButtonItem?.action)
77
+ if let cancelBtnText = config["cancelButtonText"] as? String, !cancelBtnText.isEmpty {
78
+ topItem.leftBarButtonItem = UIBarButtonItem(title: cancelBtnText, style: topItem.leftBarButtonItem?.style ?? .plain, target: topItem.leftBarButtonItem?.target, action: topItem.leftBarButtonItem?.action)
79
79
  }
80
80
 
81
- if let rightBtnText = config["rightButtonText"] as? String, !rightBtnText.isEmpty {
82
- topItem.rightBarButtonItem = UIBarButtonItem(title: rightBtnText, style: topItem.rightBarButtonItem?.style ?? .plain, target: topItem.rightBarButtonItem?.target, action: topItem.rightBarButtonItem?.action)
81
+ if let saveBtnText = config["saveButtonText"] as? String, !saveBtnText.isEmpty {
82
+ topItem.rightBarButtonItem = UIBarButtonItem(title: saveBtnText, style: topItem.rightBarButtonItem?.style ?? .plain, target: topItem.rightBarButtonItem?.target, action: topItem.rightBarButtonItem?.action)
83
83
  }
84
84
  }
85
85
  })
@@ -2,8 +2,8 @@ export interface EditorConfig {
2
2
  saveToPhoto?: boolean;
3
3
  maxDuration?: number;
4
4
  title?: string;
5
- leftButtonText?: string;
6
- rightButtonText?: string;
5
+ cancelButtonText?: string;
6
+ saveButtonText?: string;
7
7
  }
8
8
  export declare function showEditor(videoPath: string, config?: EditorConfig): Promise<void>;
9
9
  export declare function isValidVideo(videoPath: string): Promise<boolean>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAmBA,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAsB,UAAU,CAC9B,SAAS,EAAE,MAAM,EACjB,MAAM,GAAE,YAAiB,GACxB,OAAO,CAAC,IAAI,CAAC,CAoCf;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAEhE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAmBA,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAsB,UAAU,CAC9B,SAAS,EAAE,MAAM,EACjB,MAAM,GAAE,YAAiB,GACxB,OAAO,CAAC,IAAI,CAAC,CAoCf;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAEhE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-video-trim",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Video trimmer for your React Native app",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
package/src/index.tsx CHANGED
@@ -21,8 +21,8 @@ export interface EditorConfig {
21
21
  saveToPhoto?: boolean;
22
22
  maxDuration?: number;
23
23
  title?: string;
24
- leftButtonText?: string;
25
- rightButtonText?: string;
24
+ cancelButtonText?: string;
25
+ saveButtonText?: string;
26
26
  }
27
27
 
28
28
  export async function showEditor(