zoukankan      html  css  js  c++  java
  • 录制视频

    #import <MobileCoreServices/MobileCoreServices.h>

    <UIVideoEditorControllerDelegate>//编辑视频

    @property (strong, nonatomic) NSString *pathToRecordedVideo;

    - (IBAction)editVideo:(id)sender;


    - (IBAction)takePicture:(id)sender { // Make sure camera is available if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] == NO) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Camera Unavailable" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil, nil]; [alert show]; return; } if (self.imagePicker == nil) { self.imagePicker = [[UIImagePickerController alloc] init]; self.imagePicker.delegate = self; self.imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; self.imagePicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera]; self.imagePicker.allowsEditing = YES; } [self presentViewController:self.imagePicker animated:YES completion:NULL]; }
    -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
    {
        NSString * mediaType = [info objectForKey: UIImagePickerControllerMediaType];
        
        if (CFStringCompare((__bridge CFStringRef) mediaType, kUTTypeMovie, 0) == kCFCompareEqualTo)
        {
            NSString * moviePath = [[info objectForKey: UIImagePickerControllerMediaURL] path];

            self.pathToRecordedVideo = moviePath;

    
    
            if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum (moviePath))
            {
                UISaveVideoAtPathToSavedPhotosAlbum (moviePath, nil, nil, nil);
            }
        }
        UIImage * image = (UIImage *)[info objectForKey:UIImagePickerControllerEditedImage];
        UIImageWriteToSavedPhotosAlbum (image, nil, nil , nil);
        self.imageView.image = image;
        self.imageView.contentMode = UIViewContentModeScaleAspectFill;
        [self dismissViewControllerAnimated:YES completion:NULL];
    }
    
    - (void) imagePickerControllerDidCancel: (UIImagePickerController *) picker
    {
        [self dismissViewControllerAnimated:YES completion:NULL];
    }
    - (IBAction)editVideo:(id)sender
    {
        if (self.pathToRecordedVideo)
        {
            UIVideoEditorController *editor = [[UIVideoEditorController alloc] init];
            editor.videoPath = self.pathToRecordedVideo;
            editor.delegate = self;
            [self presentViewController:editor animated:YES completion:NULL];
        }
        else
        {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"No Video Recorded Yet" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil, nil];
            [alert show];
        }
    }
    -(void)videoEditorController:(UIVideoEditorController *)editor didSaveEditedVideoToPath:(NSString *)editedVideoPath
    {
        self.pathToRecordedVideo = editedVideoPath;
        if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum (editedVideoPath))
        {
            UISaveVideoAtPathToSavedPhotosAlbum (editedVideoPath, nil, nil, nil);
        }
        [self dismissViewControllerAnimated:YES completion:NULL];
    }
    
    -(void)videoEditorControllerDidCancel:(UIVideoEditorController *)editor
    {
        [self dismissViewControllerAnimated:YES completion:NULL];
    }
  • 相关阅读:
    javamail模拟邮箱功能发送电子邮件-基础实战篇(javamail API电子邮件实例)
    javaScript的函数(Function)对象的声明(@包括函数声明和函数表达式)
    java后台调用HttpURLConnection类模拟浏览器请求(一般用于接口调用)
    java 常用concurrent类
    安装php5.5
    Unix 哲学
    mysql创建用户两次授权
    python知识点 07-11
    Gradle 1.3之前的Publishing artifacts
    mysql编码详解
  • 原文地址:https://www.cnblogs.com/fengmin/p/5520895.html
Copyright © 2011-2022 走看看