Frage

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];
War es hilfreich?

Lösung

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;
        }
    }
}

Andere Tipps

you get device name follwing method

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

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top