用什么代替QTCaptureDevice?

时间:2014-03-19 01:21:56

标签: objective-c macos cocoa

我注意到在QTCaptureDevice(https://developer.apple.com/library/mac/documentation/quicktime/reference/QTCaptureDevice_Class/Reference/Reference.html)的文档中,它似乎正在折旧?

你应该用什么代替进行屏幕/录音?

1 个答案:

答案 0 :(得分:2)

QTKit逐步淘汰,我们鼓励您使用AVFoundation。它提供了类似的功能和更多

在这种情况下使用AVCaptureDevice来制作AVCaptureSession

e.g。设置相机视图

AVCaptureDevice * captureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
AVCaptureDeviceInput * captureDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:captureDevice error:error];

AVCaptureSession * captureSession = [[AVCaptureSession alloc] init];    
[captureSession beginConfiguration];
captureSession.sessionPreset = AVCaptureSessionPresetPhoto;
[captureSession addInput:captureDeviceInput];
AVCaptureStillImageOutput * output = [[AVCaptureStillImageOutput alloc] init];
[captureSession addOutput:output];

[captureSession commitConfiguration];    
[captureSession startRunning];