3
在相機之間切換時,我正面臨非常奇怪的問題。當用戶從前向後切換攝像頭時,用戶可以看到紅色狀態欄一秒鐘後自動消失,並帶有向上滑動動畫。我搜索了很多谷歌&堆棧溢出,但沒有運氣。我發現這個question,但它與audio recording
有關。這裏是我的代碼使用AVFoundation切換攝像頭時顯示的紅色狀態欄
-(void)toggleCameraIsFront:(BOOL)isFront
{
AVCaptureDevicePosition desiredPosition;
if (isFront) {
desiredPosition = AVCaptureDevicePositionFront;
self.videoDeviceType = VideoDeviceTypeFrontCamera;
}
else {
desiredPosition = AVCaptureDevicePositionBack;
self.videoDeviceType = VideoDeviceTypeRearCamera;
}
for (AVCaptureDevice *d in [AVCaptureDevice devicesWithMediaType: AVMediaTypeVideo])
{
if ([d position] == desiredPosition)
{
AVCaptureDeviceInput *videoDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:d error:nil];
[self.session beginConfiguration];
[self.session removeInput:self.videoInput];
if ([self.session canAddInput:videoDeviceInput])
{
[self.session addInput:videoDeviceInput];
[self setVideoInput:videoDeviceInput];
}
else
{
[self.session addInput:self.videoInput];
}
[self.session commitConfiguration];
break;
}
}
}
相機切換&嘗試從AVCaptureVideoDataOutputSampleBufferDelegate
沒有得到所謂的再記錄以下方法視頻後也。
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection
任何形式的幫助,高度讚賞。謝謝。
這是什麼運氣? –