8

I'm using UIVideoEditorController, but the success delegate method called twice for me. However, all pointers of all passed objects tell it sends exactly the same data.

let editor = UIVideoEditorController()
editor.videoMaximumDuration = 10.0
editor.videoQuality = .typeIFrame1280x720
editor.delegate = self
editor.videoPath = // some path goes here
self.present(editor, animated: true, completion: nil)

And then the following method prints "here" 2 times.

func videoEditorController(_ editor: UIVideoEditorController, didSaveEditedVideoToPath editedVideoPath: String) {
    print("here")
    self.dismiss(animated: true, completion: nil)
}
Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
Stas Ivanov
  • 917
  • 1
  • 10
  • 22
  • I see this bug when I link against iOS 13, i.e. build with Xcode 11. If I build with Xcode 10 or earlier, the callback is called only once for me. – Theo Sep 13 '19 at 17:18

5 Answers5

6
func videoEditorController(_ editor: UIVideoEditorController, didSaveEditedVideoToPath editedVideoPath: String) {
    editor.delegate = nil
    editor.dismiss(animated: true)
}
  • 2
    Thank you for this code snippet, which might provide some limited short-term help. A proper explanation [would greatly improve](//meta.stackexchange.com/q/114762) its long-term value by showing *why* this is a good solution to the problem, and would make it more useful to future readers with other, similar questions. Please [edit] your answer to add some explanation, including the assumptions you've made. – Toby Speight Nov 28 '19 at 18:08
  • it's working, thanks – Duc Trung Mai Jul 23 '23 at 15:14
1

yes, I know, this bad way but workin :)

var isSaved:Bool = false

func videoEditorController(_ editor: UIVideoEditorController, didSaveEditedVideoToPath editedVideoPath: String) {
   if(!isSaved) {
      print("here")
      self.isSaved = true
   }
       self.dismiss(animated: true, completion: nil)
   }
e.john
  • 31
  • 1
0

Can you please debug that you UIViewController that using UIVideoEditorController is reallocating properly when user leaves the screen. Like after leaving the screen or going back from the screen.

Might be one object of your UIViewController in memory that's why your method called twice.

To debug this

  • create deinit{ print("deallocating") } for you UIViewController.
  • add break point on print.
  • then make sure deinit is getting called.

Hope it will help you. :)

bestiosdeveloper
  • 2,339
  • 1
  • 11
  • 28
0

this work for me

- (void)videoEditorController:(UIVideoEditorController *)editor didSaveEditedVideoToPath:(NSString *)editedVideoPath {

    [editor dismissViewControllerAnimated:YES completion:^{
        NSLog(@"path = %@", editedVideoPath);
    }];    
}
L.logan
  • 1
  • 1
0
func videoEditorController(_ editor: UIVideoEditorController,
 didSaveEditedVideoToPath editedVideoPath: String) {

    // This is the trimed video url
    print(editedVideoPath)
    
   dismiss(animated:true)
}
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
HafizAnser
  • 553
  • 6
  • 10