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];
    }
  • 相关阅读:
    【报名有奖】相约2020 RT-Thread 开发者大会RDC
    基于RT-Thread的人体健康监测系统
    RT-Thread的位图调度算法分析(最新版)
    QEMU让你无需开发板即可玩溜RT-Thread~
    WPF TreeView 控件 HierarchicalDataTemplate 绑定节点及自定义节点的 样式
    转载 Prism之使用EventAggregation进行模块间通信 (http://www.cnblogs.com/li-xiao/archive/2011/04/20/2022962.html)
    创建简单的WCF程序(计算器)
    Arcgis Javascript API 离线部署
    回调函数
    Zookeeper 详细介绍 尤其树形结构 (转)
  • 原文地址:https://www.cnblogs.com/fengmin/p/5520895.html
Copyright © 2011-2022 走看看