WWDC2023 "Support external cameras in your iPadOS app" presentation sample code

Hi,

I saw a presentation / demonstration of AVCam app being modified to use any external USB camera in this video (https://developer.apple.com/videos/play/wwdc2023/10106/). The presenter mentions that the sample code will be available for download, however I am unable to find the same. Can someone point me to the mentioned sample code?

Thanks!

Post not yet marked as solved Up vote post of usbapps Down vote post of usbapps
937 views

Replies

I haven't found the modified sample, but you can download the original code (linked in the WWDC video description) and modify it by following the instructions in the video. At least the slide showing how to preferentially detect and use an external camera is visible for a few seconds, I haven't bothered with the rest yet (which deal with hot plugging etc). It is a couple of lines of code to changes to get a picture from your external camera.

Thanks for your reply.

I tried the initial modification shown in the video to select the default camera as external camera.

            if let externalCamera = AVCaptureDevice.default(.external, for: .video, position: .unspecified) {
                defaultVideoDevice = externalCamera
                print("External camera selected")
            }
            else if let dualCameraDevice = AVCaptureDevice.default(.builtInDualCamera, for: .video, position: .back) {
                defaultVideoDevice = dualCameraDevice
            }

Test setup details:

  1. I am testing on my iPad Pro 11" 4 Gen running iPadOS 17 (public beta).
  2. I use Xcode 15 beta 4 to use the iPad as the run destination (wireless mode).
  3. An external USB webcam is connected to the iPad during the test. This camera is working when I test using the FaceTime app.

However, I see the below error on app start.

Capture session runtime error: related decl 'e' for AVError(_nsError: Error Domain=AVFoundationErrorDomain Code=-11819 "Cannot Complete Action" UserInfo={NSLocalizedDescription=Cannot Complete Action, NSLocalizedRecoverySuggestion=Try again later.})

Error Code = AVError(rawValue: -11819)

Did you do any additional modifications in the project for your tests?

Thanks!

sorry, no idea, that's the only modification I made.