开发者

block UIImagePickerController Movie Recording

I have an app where I'm trying to capture voice recordings and video recordings. I can do one or the other but not both and the problem seems to be my AVAudioSession. In order to record and playback the audio I'm using the following code:

NSError *error = nil;

audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];

UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
AudioSessionSetProperty(kAudioSessionProperty_OverrideAudioRoute, sizeof(audioRouteOverride), &audioRouteOverride);

[audioSession setActive:YES error:&error];

In order to capture video I'm using UIImagePickerController:

- (BOOL)startCameraControllerFromViewController: (UIViewController*) controller usingDelegate: (id <UIImagePickerControllerDelegate, UINavigationControllerDelegate>) delegate
{
    NSLog(@"AAVC startCameraControllerFromViewController");

    if (([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] == NO) || (delegate == nil) || (controller == nil))
    {
        return NO;
    }

    cameraUI = [[UIImagePickerController alloc] init]; 
    [cameraUI setSourceType:UIImagePickerControllerSourceTypeCamera];
    [cameraUI setAllowsEditing:NO];
    [cameraUI setDelegate:delegate];

    NSLog(@"cameraUI retainCount = %i", [cameraUI retainCount]);

    AccessAndrewAppDelegate *AppDelegate = [[UIApplication sharedApplication] delegate];

    if (AppDelegate.isMovie)
    {
        [cameraUI setMediaTypes:[[NSArray alloc] initWithObjects:(NSString *) kUTTypeMovie, nil]];
        [cameraUI setVideoQuality:UIImagePickerControllerQualityTypeLow];
        AppDelegate.isMovie = NO;
    }
    else
    {
        [cameraUI setMediaTypes:[[NSArray alloc] initWithObjects:(NSString *) kUTTypeImage, nil]];
    }

    [controller presentModalViewController:cameraUI animated:YES];

    return YES;
}

What happens is 开发者_开发知识库when using the AVAudioSession code and trying to record a video the shutter will open and then close and freeze. If I comment out the AVAudioSession configuration the video records; however, the voice record won't playback properly. Any ideas?


This has been resolved. It was a problem with my AVAudioSession in the app delegate. Needed to add some if logic to reconfigure the audio session if the camera was launched to record movies

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜