LoginSignup
5
3

More than 1 year has passed since last update.

ビルトインのFaceTimeカメラだけではなく、接続されている他のカメラの選択肢を調べる方法です。

引用元:

let discoverySession = AVCaptureDevice.DiscoverySession(deviceTypes: [.builtInWideAngleCamera, .externalUnknown], mediaType: .video, position: .unspecified)
let captureSession = AVCaptureSession()
        
for device in discoverySession.devices {
    print(device.localizedName)
            
    let videoInput = try! AVCaptureDeviceInput(device: device)
    let available: String = captureSession.canAddInput(videoInput) ? "true": "false"
            
    print("\tConnected: \(device.isConnected)")
    print("\tSuspended: \(device.isSuspended)")
    print("\tAvailable: \(available)")
    print("\tIs In Use: \(device.isInUseByAnotherApplication)")
    print()
}

FaceTime HD Camera (Built-in)
Connected: true
Suspended: false
Available: true
Is In Use: false

C922 Pro Stream Webcam #4
Connected: true
Suspended: false
Available: true
Is In Use: false

🐣


フリーランスエンジニアです。
お仕事のご相談こちらまで
rockyshikoku@gmail.com

Core MLやARKitを使ったアプリを作っています。
機械学習/AR関連の情報を発信しています。

Twitter
Medium
GitHub

5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3