ios videoMaximumDuration不限制持续时间

tzxcd3kk  于 2023-06-07  发布在  iOS
关注(0)|答案(2)|浏览(211)

我希望用户从他的库中选择一个视频,并将其限制为45秒(像WhatsApp -您可以编辑视频,将被发送的视频不超过45秒。
但是如果我使用下面的代码,它会选择一个视频,而不管它的持续时间,我不能修剪它(用一个视频测试,长度为1分钟)

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];

在WhatsApp中,我得到以下屏幕,我想重现:

aoyhnmkz

aoyhnmkz1#

在显示控制器之前,请确保将allowsEditing设置为YES。
imagePickerController.allowsEditing = YES;

njthzxwz

njthzxwz2#

在设置视频持续时间之前,请确保将allowsEditing设置为true
按这个顺序

imagePickerController.videoMaximumDuration = 45.0
 imagePickerController.allowsEditing = true

相关问题