美文网首页iosiOS_UIKit
UIVideoEditorController视频编辑

UIVideoEditorController视频编辑

作者: 絮语时光杨 | 来源:发表于2018-05-14 15:17 被阅读4次

    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视频编辑

        本文链接:https://www.haomeiwen.com/subject/tpqjdftx.html