2017-10-14 1 views
3

추가 오디오 장치가 UIImpactFeedbackGenerator을 해제하는 것 같다합니다.UIImpactFeedbackGenerator 작동하지 않음이 AVCaptureSession</strong><strong>에 마이크의 오디오 입력을 추가 AVCaptureSession

let audioDevice = AVCaptureDevice.defaultDevice(withMediaType: AVMediaTypeAudio) 
let audioDeviceInput = try AVCaptureDeviceInput(device: audioDevice) 
if self.session.canAddInput(audioDeviceInput) { 
    self.session.addInput(audioDeviceInput) 
} 

일단 오디오 장치가 제거되면 피드백이 다시 시작됩니다.

정상적인 동작입니까? 이 문제를 해결할 방법이 있습니까?

동영상 모드에서 iOS 카메라 앱을 사용하고 미리보기 이미지를 길게 누르면 피드백이 작동하는 것처럼 보입니다. 그럼이 문제를 해결할 방법이 있어야합니까?

답변

3

이것은 의도적 인 것으로 보입니다.

캡처 세션을 중지하고 햅틱을 재생 한 다음 카메라 앱이하는 것처럼 보이는 캡처 세션을 다시 시작할 수 있습니다. 카메라 피드를 들으면 마지막 캡처 한 프레임의 흐린 정적 이미지로 이동합니다. . 예 :

self.session.stopRunning() 
// Play haptic 
UINotificationFeedbackGenerator().notificationOccurred(.warning) 
// Not completely sure if this delay is needed but you might need to wait until the run loop after the haptic plays to resume capture session 
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) 
{ 

    self.session.startRunning() 
} 
관련 문제