UIVideoEditorController视频编辑

UIVideoEditorController类包含了由系统提供的界面,使用户可以交互式的剪切视频

  • (IBAction)click:(UIButton *)sender {
    UIImagePickerController *myImagePickerController = [[UIImagePickerController alloc] init];
    myImagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    myImagePickerController.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:myImagePickerController.sourceType];
    myImagePickerController.delegate = self;
    myImagePickerController.editing = NO;
    [self presentViewController:myImagePickerController animated:YES completion:nil];
    }

pragma mark - UIImagePickerControllerDelegate

  • (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
    [picker dismissViewControllerAnimated:YES completion:^{
    NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
    if([mediaType isEqualToString:@"public.movie"]) {
    NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL];

                  UIVideoEditorController *editVC;              
            // 检查这个视频资源能不能被修改 
                 if ([UIVideoEditorController canEditVideoAtPath:videoURL.path]) {  
                        editVC = [[UIVideoEditorController alloc] init]; 
                        editVC.videoPath = videoURL.path; editVC.delegate = self; 
                 } 
                 [self presentViewController:editVC animated:YES completion:nil];
           } 
       }];
    

}

//编辑成功后的Video被保存在沙盒的临时目录中

  • (void)videoEditorController:(UIVideoEditorController *)editor didSaveEditedVideoToPath:(NSString *)editedVideoPath {
    NSLog(@"+++++++++++++++%@",editedVideoPath);
    }

// 编辑失败后调用的方法

  • (void)videoEditorController:(UIVideoEditorController *)editor didFailWithError:(NSError *)error {
    NSLog(@"%@",error.description);
    }

//编辑取消后调用的方法

  • (void)videoEditorControllerDidCancel:(UIVideoEditorController *)editor {

}

你可能感兴趣的:(UIVideoEditorController视频编辑)