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];
    }
  • 相关阅读:
    dtoj4697. 格
    dtoj3317. 人类基因(human)
    Codeforces Round #661 (Div. 3)
    Codeforces Round #667 (Div. 3).md
    Codeforces Round #674 (Div. 3)
    Codeforces Round #693 (Div. 3)
    Educational Codeforces Round 102 (Rated for Div. 2)(A-E)
    Codeforces Round #695 (Div. 2)
    2020 ICPC 上海(8/13)
    kuangbin带你飞 专题十五 数位DP
  • 原文地址:https://www.cnblogs.com/fengmin/p/5520895.html
Copyright © 2011-2022 走看看