Skip to content

Commit 99e74b8

Browse files
committed
Video device error handling
1 parent 6846414 commit 99e74b8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Sources/LiveKit/SwiftUI/LocalMedia.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,13 @@ open class LocalMedia: ObservableObject {
197197
/// Selects a video capture device.
198198
/// - Parameter videoDevice: The ``AVCaptureDevice`` to select.
199199
public func select(videoDevice: AVCaptureDevice) async {
200-
selectedVideoDeviceID = videoDevice.uniqueID
201-
202200
guard let cameraCapturer = getCameraCapturer() else { return }
203-
let captureOptions = CameraCaptureOptions(device: videoDevice)
204-
_ = try? await cameraCapturer.set(options: captureOptions)
201+
do {
202+
try await cameraCapturer.set(options: .init(device: videoDevice))
203+
selectedVideoDeviceID = videoDevice.uniqueID
204+
} catch {
205+
self.error = .mediaDevice(error)
206+
}
205207
}
206208

207209
/// Switches the camera position.

0 commit comments

Comments
 (0)