Newbee
Newbee

Reputation: 3301

How to get the iOS devices camera name?

Does IOS capture devices and playback devices have any name or path? Usually we can able to get path for connected camera and its name in windows, I guess in Mac also we can do that. Anyone have idea about how to get name and path of capture and playback devices on IOS?

  // RETURNS HOW MANY AUDIO CAPTURE DEVICES ARE THERE... 
  for eg: [[AVCaptureDevice devicesWithMediaType:AVMediaTypeAudio] count];

Upvotes: 1

Views: 1395

Answers (3)

Bill Cheswick
Bill Cheswick

Reputation: 643

Alas, "devices" is deprecated in iOS 10.0. Use AVCaptureDeviceDiscoverySession instead.

Upvotes: 0

Newbee
Newbee

Reputation: 3301

NSArray *devices = [AVCaptureDevice devices];
AVCaptureDevice *frontCamera;
AVCaptureDevice *backCamera;

for (AVCaptureDevice *device in devices) {

    NSLog(@"Device name: %@", [device localizedName]);

    if ([device hasMediaType:AVMediaTypeVideo]) {

        if ([device position] == AVCaptureDevicePositionBack) {
            NSLog(@"Device position : back");
            backCamera = device;
        }
        else {
            NSLog(@"Device position : front");
            frontCamera = device;
        }
    }
}

Upvotes: 3

Sumit Mundra
Sumit Mundra

Reputation: 3901

you get device name follwing method

NSString *name =[[UIDevice currentDevice] name]);

Upvotes: 0

Related Questions