我正在尝试在以下 QTCaptureSession 中添加两个输入:
mainSession = [[QTCaptureSession alloc] init];
BOOL success;
NSError* error;
QTCaptureDevice *videoDevice = [QTCaptureDevice defaultInputDeviceWithMediaType:@"QTMediaTypeVideo"];
success = [videoDevice open:&error];
QTCaptureDevice *audioDevice = [QTCaptureDevice defaultInputDeviceWithMediaType:@"QTMediaTypeSound"];
success = [audioDevice open:&error];
//video = [[QTCaptureDeviceInput alloc] initWithDevice:videoDevice];
//success = [mainSession addInput:video error:&error];
//audio = [[QTCaptureDeviceInput alloc] initWithDevice:audioDevice];
//success = [mainSession addInput:audio error:&error];
output = [[QTCaptureMovieFileOutput alloc] init];
success = [mainSession addOutput:output error:&error];
[output setDelegate:self];
[movieView setCaptureSession:mainSession];
[mainWindow makeKeyAndOrderFront:NSApp];
[mainSession startRunning];
我已经确定注释掉的部分是错误的来源:
[QTCaptureDeviceInput initWithDevice:]-
无法使用未打开的设备初始化设备输入。
我在打开方法之后探测了我的“成功”变量,它是肯定的。那么为什么该方法认为设备未打开?