react-native-video-trim 6.0.11 → 6.0.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.
Files changed (2) hide show
  1. package/ios/VideoTrim.swift +9 -103
  2. package/package.json +1 -4
@@ -3,7 +3,6 @@ import Photos
3
3
  import ffmpegkit
4
4
 
5
5
  let FILE_PREFIX = "trimmedVideo"
6
- let BEFORE_TRIM_PREFIX = "beforeTrim"
7
6
 
8
7
  @objc(VideoTrimSwift)
9
8
  public class VideoTrim: RCTEventEmitter, AssetLoaderDelegate, UIDocumentPickerDelegate {
@@ -343,12 +342,12 @@ public class VideoTrim: RCTEventEmitter, AssetLoaderDelegate, UIDocumentPickerDe
343
342
 
344
343
  cmds.append(contentsOf: [
345
344
  "-i",
346
- "\(inputFile)",
345
+ inputFile.path,
347
346
  "-c",
348
347
  "copy",
349
348
  "-metadata",
350
349
  "creation_time=\(dateTime)",
351
- outputFile!.absoluteString
350
+ outputFile!.path
352
351
  ])
353
352
 
354
353
  print("Command: ", cmds.joined(separator: " "))
@@ -465,13 +464,7 @@ public class VideoTrim: RCTEventEmitter, AssetLoaderDelegate, UIDocumentPickerDe
465
464
  // New Arch
466
465
  @objc(trim:url:config:)
467
466
  public func _trim(inputFile: String, config: NSDictionary, completion: @escaping ([String: Any]) -> Void) {
468
- var destPath: URL?
469
-
470
- if inputFile.hasPrefix("http://") || inputFile.hasPrefix("https://") {
471
- destPath = URL(string: inputFile)
472
- } else {
473
- destPath = renameFile(at: URL(string: inputFile)!, newName: BEFORE_TRIM_PREFIX)
474
- }
467
+ let destPath = URL(string: inputFile)
475
468
 
476
469
  guard let destPath = destPath else {
477
470
  let result = [
@@ -511,12 +504,12 @@ public class VideoTrim: RCTEventEmitter, AssetLoaderDelegate, UIDocumentPickerDe
511
504
 
512
505
  cmds.append(contentsOf: [
513
506
  "-i",
514
- "\(destPath.absoluteString)",
507
+ destPath.path,
515
508
  "-c",
516
509
  "copy",
517
510
  "-metadata",
518
511
  "creation_time=\(dateTime)",
519
- outputFile.absoluteString
512
+ outputFile.path
520
513
  ])
521
514
 
522
515
  print("Command: ", cmds.joined(separator: " "))
@@ -706,40 +699,6 @@ public class VideoTrim: RCTEventEmitter, AssetLoaderDelegate, UIDocumentPickerDe
706
699
  ]
707
700
  self.emitEventToJS("onError", eventData: eventPayload)
708
701
  }
709
-
710
- private func renameFile(at url: URL, newName: String) -> URL? {
711
- let fileManager = FileManager.default
712
-
713
- // Get the directory of the existing file
714
- let directory = url.deletingLastPathComponent()
715
-
716
- // Get the file extension
717
- let fileExtension = url.pathExtension
718
-
719
- // Create the new file URL with the new name and the same extension
720
- let newFileURL = directory.appendingPathComponent(newName).appendingPathExtension(fileExtension)
721
-
722
- // Check if a file with the new name already exists
723
- if fileManager.fileExists(atPath: newFileURL.path) {
724
- do {
725
- // If the file exists, remove it first to avoid conflicts
726
- try fileManager.removeItem(at: newFileURL)
727
- } catch {
728
- print("Error removing existing file: \(error)")
729
- return nil
730
- }
731
- }
732
-
733
- do {
734
- // Rename (move) the file
735
- try fileManager.moveItem(at: url, to: newFileURL)
736
- print("File renamed successfully to \(newFileURL.absoluteString)")
737
- return newFileURL
738
- } catch {
739
- print("Error renaming file: \(error)")
740
- return nil
741
- }
742
- }
743
702
  }
744
703
 
745
704
  // MARK: @objc instance methods
@@ -751,63 +710,10 @@ extension VideoTrim {
751
710
  return
752
711
  }
753
712
  editorConfig = config
713
+ print("Show editor called with URI: \(uri)")
754
714
 
755
- //
756
- // saveToPhoto = config["saveToPhoto"] as? Bool ?? false
757
- //
758
- // removeAfterSavedToPhoto = config["removeAfterSavedToPhoto"] as? Bool ?? false
759
- // removeAfterFailedToSavePhoto = config["removeAfterFailedToSavePhoto"] as? Bool ?? false
760
- // removeAfterSavedToDocuments = config["removeAfterSavedToDocuments"] as? Bool ?? false
761
- // removeAfterFailedToSaveDocuments = config["removeAfterFailedToSaveDocuments"] as? Bool ?? false
762
- // removeAfterShared = config["removeAfterShared"] as? Bool ?? false
763
- // removeAfterFailedToShare = config["removeAfterFailedToShare"] as? Bool ?? false
764
- //
765
- // enableCancelDialog = config["enableCancelDialog"] as? Bool ?? true
766
- // cancelDialogTitle = config["cancelDialogTitle"] as? String ?? "Warning!"
767
- // cancelDialogMessage = config["cancelDialogMessage"] as? String ?? "Are you sure want to cancel?"
768
- // cancelDialogCancelText = config["cancelDialogCancelText"] as? String ?? "Close"
769
- // cancelDialogConfirmText = config["cancelDialogConfirmText"] as? String ?? "Proceed"
770
- //
771
- // enableSaveDialog = config["enableSaveDialog"] as? Bool ?? true
772
- // saveDialogTitle = config["saveDialogTitle"] as? String ?? "Confirmation!"
773
- // saveDialogMessage = config["saveDialogMessage"] as? String ?? "Are you sure want to save?"
774
- // saveDialogCancelText = config["saveDialogCancelText"] as? String ?? "Close"
775
- // saveDialogConfirmText = config["saveDialogConfirmText"] as? String ?? "Proceed"
776
- // trimmingText = config["trimmingText"] as? String ?? "Trimming video..."
777
- // fullScreenModalIOS = config["fullScreenModalIOS"] as? Bool ?? false
778
- // isVideoType = (config["type"] as? String ?? "video") == "video"
779
- // outputExt = config["outputExt"] as? String ?? "mp4"
780
- // openDocumentsOnFinish = config["openDocumentsOnFinish"] as? Bool ?? false
781
- // openShareSheetOnFinish = config["openShareSheetOnFinish"] as? Bool ?? false
782
- //
783
- // closeWhenFinish = config["closeWhenFinish"] as? Bool ?? true
784
- // enableCancelTrimming = config["enableCancelTrimming"] as? Bool ?? true
785
- // cancelTrimmingButtonText = config["cancelTrimmingButtonText"] as? String ?? "Cancel"
786
- // enableCancelTrimmingDialog = config["enableCancelTrimmingDialog"] as? Bool ?? true
787
- // cancelTrimmingDialogTitle = config["cancelTrimmingDialogTitle"] as? String ?? "Warning!"
788
- // cancelTrimmingDialogMessage = config["cancelTrimmingDialogMessage"] as? String ?? "Are you sure want to cancel trimming?"
789
- // cancelTrimmingDialogCancelText = config["cancelTrimmingDialogCancelText"] as? String ?? "Close"
790
- // cancelTrimmingDialogConfirmText = config["cancelTrimmingDialogConfirmText"] as? String ?? "Proceed"
791
- // alertOnFailToLoad = config["alertOnFailToLoad"] as? Bool ?? true
792
- // alertOnFailTitle = config["alertOnFailTitle"] as? String ?? "Error"
793
- // alertOnFailMessage = config["alertOnFailMessage"] as? String ?? "Fail to load media. Possibly invalid file or no network connection"
794
- // alertOnFailCloseText = config["alertOnFailCloseText"] as? String ?? "Close"
795
- //
796
- // if let cancelBtnText = config["cancelButtonText"] as? String, !cancelBtnText.isEmpty {
797
- // self.cancelButtonText = cancelBtnText
798
- // }
799
- //
800
- // if let saveButtonText = config["saveButtonText"] as? String, !saveButtonText.isEmpty {
801
- // self.saveButtonText = saveButtonText
802
- // }
803
-
804
- var destPath: URL?
805
-
806
- if uri.hasPrefix("http://") || uri.hasPrefix("https://") {
807
- destPath = URL(string: uri)
808
- } else {
809
- destPath = renameFile(at: URL(string: uri)!, newName: BEFORE_TRIM_PREFIX)
810
- }
715
+ let destPath = URL(string: uri)
716
+ print("Destination Path: \(destPath!.absoluteString), path: \(destPath!.path)")
811
717
 
812
718
  guard let destPath = destPath else { return }
813
719
 
@@ -978,7 +884,7 @@ extension VideoTrim {
978
884
  let directoryContents = try FileManager.default.contentsOfDirectory(at: documentsDirectory, includingPropertiesForKeys: nil)
979
885
 
980
886
  for fileURL in directoryContents {
981
- if fileURL.lastPathComponent.starts(with: FILE_PREFIX) || fileURL.lastPathComponent.starts(with: BEFORE_TRIM_PREFIX) {
887
+ if fileURL.lastPathComponent.starts(with: FILE_PREFIX) {
982
888
  files.append(fileURL)
983
889
  }
984
890
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-video-trim",
3
- "version": "6.0.11",
3
+ "version": "6.0.12",
4
4
  "description": "Video trimmer for your React Native app",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -88,9 +88,6 @@
88
88
  "react": "*",
89
89
  "react-native": "*"
90
90
  },
91
- "workspaces": [
92
- "example"
93
- ],
94
91
  "packageManager": "yarn@1.2.2",
95
92
  "jest": {
96
93
  "preset": "react-native",