Reputation: 20
I have this code which assumes that an AV decide is connected...
AVCaptureDeviceInput *device_input = [[AVCaptureDeviceInput alloc] initWithDevice :
[AVCaptureDevice devicesWithMediaType : AVMediaTypeVideo][0] error : nil];
How can I modify that code so that I get a message like this...
if (No AV devices were detected)
NSLog(@"No AV devices were detected");
else
NSLog(@"The following devices were detected...");
Thanks, Len.
Upvotes: 0
Views: 82
Reputation: 931
If you have to check for audio device you can use below code-
-(void)checkForDevice{
AVCaptureDevice *audioDevice = [[AVCaptureDevice devicesWithMediaType:AVMediaTypeAudio] firstObject];
AVCaptureDeviceInput *audioDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:audioDevice error:&error];
if (error)
{
NSLog(@"%@", error); //problem with the device
}
else
{
//device is available
}
}
In the similar way you can check for vedio and other AV Devices.
Upvotes: 1