Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

videoMaximumDuration doesn't limit the duration

I would like the user to pick a video from his libary and limit it to 45 seconds (Like WhatsApp - you can edit the video and the video which will be sent is not longer than 45 seconds.

But if I use the following code, it does pick a video regardless of the duration, and I cant trim it (Tested it with a video, length 1 minute)

UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
        imagePickerController.delegate = self; 
        imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        imagePickerController.videoQuality = UIImagePickerControllerQualityTypeLow;
        imagePickerController.videoMaximumDuration = 45.0f; //?
        imagePickerController.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary];

        [[self parentViewController] presentModalViewController:imagePickerController animated:YES];
        [imagePickerController release];

In WhatsApp, I get the following screen, which I want to reproduce: enter image description here

like image 377
Mariusz B. Avatar asked Dec 04 '22 04:12

Mariusz B.


1 Answers

make sure you set allowsEditing to YES before presenting the controller.

imagePickerController.allowsEditing = YES;

like image 81
Ethan Chen Avatar answered Dec 23 '22 22:12

Ethan Chen