AVCaptureDevice在模拟器上始终为null [英] AVCaptureDevice is always null on simulator
问题描述
我正在尝试捕获实时麦克风音频数据。
I am trying to capture live microphone audio data.
我从苹果示例中获取了以下内容 AVCaptureSession
。
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
和 audioInput
都是空的。
推荐答案
是的,它应该是。因为模拟器没有任何麦克风。您应该始终在真实设备上测试任何音频,视频和渲染相关任务。
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.
硬件限制虽然可以在iOS模拟器中模拟iOS设备的大部分功能
,但有一些硬件功能
必须直接在设备上测试。
无法模拟的硬件功能包括:
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:
加速度计
陀螺仪
相机
邻近
传感器麦克风输入
这篇关于AVCaptureDevice在模拟器上始终为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!