react-native-video-trim 1.0.2 → 1.0.4

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.
@@ -1,2 +1,2 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android">
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.videotrim">
2
2
  </manifest>
@@ -7,6 +7,7 @@ class VideoTrim: RCTEventEmitter, UIVideoEditorControllerDelegate, UINavigationC
7
7
  private var mSaveToPhoto = true
8
8
  private var mMaxDuration: Int?
9
9
  private var hasListeners = false
10
+ private var shouldFireFinishEvent = true
10
11
 
11
12
  @objc
12
13
  static override func requiresMainQueueSetup() -> Bool {
@@ -79,9 +80,14 @@ class VideoTrim: RCTEventEmitter, UIVideoEditorControllerDelegate, UINavigationC
79
80
 
80
81
  func videoEditorController(_ editor: UIVideoEditorController,
81
82
  didSaveEditedVideoToPath editedVideoPath: String) {
83
+ if (!shouldFireFinishEvent) {
84
+ return
85
+ }
86
+ shouldFireFinishEvent = false
87
+
82
88
  let eventPayload: [String: Any] = ["outputPath": editedVideoPath]
83
89
  self.emitEventToJS("onFinishTrimming", eventData: eventPayload)
84
-
90
+
85
91
  if (mSaveToPhoto) {
86
92
  PHPhotoLibrary.requestAuthorization { status in
87
93
  guard status == .authorized else {
@@ -89,7 +95,7 @@ class VideoTrim: RCTEventEmitter, UIVideoEditorControllerDelegate, UINavigationC
89
95
  self.emitEventToJS("onError", eventData: eventPayload)
90
96
  return
91
97
  }
92
-
98
+
93
99
  PHPhotoLibrary.shared().performChanges({
94
100
  let request = PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: URL(fileURLWithPath: editedVideoPath))
95
101
  request?.creationDate = Date()
@@ -103,14 +109,18 @@ class VideoTrim: RCTEventEmitter, UIVideoEditorControllerDelegate, UINavigationC
103
109
  }
104
110
  }
105
111
  }
106
-
112
+
107
113
  // the edit has a known bug where it fires "didSaveEditedVideoToPath" twice, so we have to set its delete to nil right after first call
108
- editor.delegate = nil
109
-
114
+ // editor.delegate = nil
110
115
 
116
+ // but with the above solution, somehow it'll close React Native Modal when the editor controller dismissed
117
+ // so we have to create a flag shouldFireFinishEvent here
118
+
119
+
111
120
  editor.dismiss(animated: true, completion: {
112
121
  self.emitEventToJS("onHide", eventData: nil)
113
122
  self.isShowing = false
123
+ self.shouldFireFinishEvent = true // reset this flag to true once dismiss
114
124
  })
115
125
  }
116
126
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-video-trim",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Video trimmer for your React Native app",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",