Closed zhangxiangguang closed 8 years ago
I resoveled this problem, we must set a property for automaticallyConfiguresApplicationAudioSession as NO before startCameraCapture.
hi, thanks ,but why it still stoped? can you help me have a look my code here
- (BOOL)startPreviewWithView:(UIView *)view
{
#if !(TARGET_IPHONE_SIMULATOR)
GPUImageCropFilter *defaultFilter = [[GPUImageCropFilter alloc] initWithCropRegion:CGRectMake(0, 0, 1, 1)];
[self.filterQueue addObjectSafely:defaultFilter];
GPUImageView *filterView = [[GPUImageView alloc] initWithFrame:view.bounds];
filterView.fillMode = kGPUImageFillModePreserveAspectRatioAndFill;
filterView.tag = 99;
[defaultFilter addTarget:filterView];
self.filterView = filterView;
self.previewView = view;
[view addSubview:filterView];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
self.stillCamera = ({
AVCaptureDevicePosition posation = [[NSUserDefaults standardUserDefaults] integerForKey:@"WBCCameraViewControllerCameraPositionKey"];
GPUImageStillCamera *camera = [[GPUImageStillCamera alloc] initWithSessionPreset:AVCaptureSessionPresetHigh cameraPosition:posation];
camera.outputImageOrientation = UIInterfaceOrientationPortrait;
camera.horizontallyMirrorFrontFacingCamera = YES;
camera.captureSession.automaticallyConfiguresApplicationAudioSession = NO;
[camera addAudioInputsAndOutputs];
camera.delegate = self;
[camera addTarget:defaultFilter];
camera;
});
if (self.stillCamera == nil) {//不存在相机
return NO;
}
self.currentEffectFilterType = -1;
[self applyEffectFilter:0 intensity:100.0];
[self.stillCamera startCameraCapture];
return YES;
#else
return NO;
#endif
}
and if i setCategory withOption AVAudioSessionCategoryOptionMixWithOthers, the music can still play ,but with a turned down volume,maybe as it mixed.how can some app sound like the same?
hi, use GPUImageMovieWriter recording video(other music app is background playing), but set audioEncodingTarget is movieWriter, music is stoped, why? set AVAudioSession category is AVAudioSessionCategoryPlayAndRecord not working. multi audio input, output not support? thank you.