Range slider's touch (box) of video trimmer “o

2019-04-18 02:27发布

I am using FDTake (the pod wont be too important for this question but still) to select videos from Photos which works fine. However, I would also like to be able to edit videos and limit their length to about 12 seconds. To do so I looked at the code of the pod and changed line 271 to self.imagePicker.allowsEditing = true which already causes the problem I haven't been able to solve so far: The left slider's touch (box) is “off”. Since that's a rather vague description I uploaded a video and you can find it right here.

Unfortunately, I have absolutely no idea what engenders the problem and would really appreciate some help with this. I asked the creator of FDTake but apparently he thinks that Apple needs to fix this (as you'll be able to see in one of the latest closed issues).

Can someone explain how I can fix this and what is causing it?

3条回答
霸刀☆藐视天下
2楼-- · 2019-04-18 02:45

We've had the same problem here. It certainly has to do with gestures on the left side of the screen.

When you add additionalSafeAreaInsets to your UIImagePickerController it works much better.

This is what we tried:

 let imagePickerController = UIImagePickerController()
 imagePickerController.allowsEditing = true
 imagePickerController.mediaTypes = [kUTTypeMovie as String]
 imagePickerController.videoMaximumDuration = 12.0
 imagePickerController.additionalSafeAreaInsets = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)

We ended up using the UIVideoEditorController.

查看更多
太酷不给撩
3楼-- · 2019-04-18 02:52

One possible Solution: Select the video and then trim the video using PryntTrimmerView

You can use PryntTrimmerView library for trimming the videos. I have implemented this library in a sample project. You can download the running sample project from my github repo Here

The load random video button loads a random video from device's storage (photos). Therefore atleast one video file needs to be present

An Avplayer is being used for displaying the video

This is complete video

Complete video

Use the black handles to trim the video as desired

Trimming the Video

Trimming the video


Note: : Minimum Allowed distance between handles is specified in PryntTrimmerView.swift file using a private property.

/// The minimum duration allowed for the trimming. The handles won't pan further if the minimum duration is attained.
  public var minDuration: Double = 2

And this function uses this property along with video duration and frame to calculate minimum distance bw handles

private var minimumDistanceBetweenHandle: CGFloat {
    guard let asset = asset else { return 0 }
    let distance = CGFloat(minDuration) * assetPreview.contentView.frame.width / CGFloat(asset.duration.seconds)
    print("minimum distance: \(distance)")
    return distance
  }

Let me know if you encounter any problems or need more information

Thanks

查看更多
\"骚年 ilove
4楼-- · 2019-04-18 03:03

I've reproduced the issue using an UIImagePickerController directly.

Here is some code that you can call from your viewController:

 let picker = UIImagePickerController()
 picker.allowsEditing = true
 picker.mediaTypes = [String(kUTTypeMovie)]
 picker.videoMaximumDuration = 12.0

 present(picker, animated: true, completion: nil)

My guess is that there is a gesture conflict with some internal view only on the left side of the screen, once you've pulled the left handle somewhere in the middle, you can access it directly.

Also, this does not seem to be new: IOS 11 UIImagepicker for video how to move the slider to the bottom?

The best thing you can do is to file a radar to Apple.

In the meantime, you can use the library suggested by Awais Fayyaz as a workaround. (Disclaimer: I'm the author of the library, so I am biased of course). Another option would be to use an UIVideoEditorController once the user has selected the video, that component does not have any issue on iOS 11.

查看更多
登录 后发表回答