AVCaptureDevice is always null on simulator

匿名 (未验证) 提交于 2019-12-03 02:34:02

问题:

I am trying to capture live microphone audio data.

I took the following from the apple example for AVCaptureSession.

AVCaptureSession *captureSession = [[AVCaptureSession alloc] init];  AVCaptureDevice *audioCaptureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];  NSError *error = nil; AVCaptureDeviceInput *audioInput = [AVCaptureDeviceInput deviceInputWithDevice:audioCaptureDevice error:&error];  if (audioInput) {     [captureSession addInput:audioInput]; } else {     // Handle the failure.     NSLog(@"ERROR"); } 

audioCaptureDevice and audioInput are both null.

回答1:

The simulator cannot take the Mac microphone as a source. You need to use a real device to test that.



回答2:

Yes, it should be. Because simulator doesn't have any microphone. You should always test any audio, video, rendering related task on a real device.

Take a look about Limitations of Testing in iOS Simulator

Hardware Limitations While most of the functionality of iOS devices can be simulated in iOS Simulator, there are some hardware features that must be tested directly on a device. The hardware features that cannot be simulated are:

Accelerometer

Gyroscope

Camera

Proximity

Sensor Microphone Input



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!