0

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.

Hugo Tunius
  • 2,869
  • 24
  • 32
Len
  • 20
  • 1
  • 7

1 Answers1

1

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.

nilam_mande
  • 931
  • 7
  • 14
  • Thanks, (I am new to XCODE, and Stackoverflow), I used your suggestion but I am getting this [AVCaptureDeviceInput deviceInputWithDevice : videoDevice error : &error]; //Use of undeclared identifier 'error' – Len Sep 28 '15 at 23:59
  • Thanks. This will check for a built in device. How could I modify that to check for other devices attached to the Mac. I am using Video2PC digitiser attache to a digital camera and via a USB port? – Len Oct 01 '15 at 12:06
  • OK, I have abandoned that digitiser and am now using a firewire connection that works. Thanks. – Len Jun 04 '16 at 17:59