ICamera
Namespace: BlazorNative.Device
DI-injectable façade over camera photo capture. Inject this rather than the
low-level BlazorNative.Core.IMobileBridge; ICamera.CapturePhotoAsync(CaptureOptions?, CancellationToken) hands off to the
system camera UI and returns a BlazorNative.Core.PhotoResult whose
BlazorNative.Core.PhotoResult.Path is a file:// URI (a valid BnImage.Src) on
capture — a cancel, denial, missing camera or error is DATA, never an exception. The
app owns the returned file. ICamera.CheckAvailabilityAsync(CancellationToken) reports usability
without launching the UI. Register it with
ServiceCollectionExtensions.AddBlazorNativeDevice(IServiceCollection).
public interface ICamera
Methods
CapturePhotoAsync(CaptureOptions?, CancellationToken)
Launches the system camera UI and returns the terminal
BlazorNative.Core.PhotoResult. On BlazorNative.Core.CameraStatus.Captured the result's
BlazorNative.Core.PhotoResult.Path is a file:// URI to the captured JPEG
(in the app's private cache) plus its final dimensions and size — hand the path
straight to a BnImage.Src to display it. A cancel / denied / unavailable
/ error outcome is DATA (a status with a null path), never a throw. The app OWNS
the file after this returns (see the interface remarks). options
caps the file's long edge and JPEG quality; passing null (the default) uses
the documented defaults — a ~2048 px long edge and JPEG quality 85. NOTE: the
parameter is BlazorNative.Core.CaptureOptions``? rather than
CaptureOptions = default ON PURPOSE — default(CaptureOptions) zero-
initialises the struct (MaxDimension=0, Quality=0), bypassing the record's
primary-constructor defaults, so a bare default would silently request the
worst-possible quality (issue #178). null ⇒ new CaptureOptions(),
which DOES run those defaults.
ValueTask<PhotoResult> CapturePhotoAsync(CaptureOptions? options = null, CancellationToken ct = null)
Parameters
options CaptureOptions?
Returns
CheckAvailabilityAsync(CancellationToken)
Reads whether a camera is available (present + usable) WITHOUT
launching the capture UI — for a UI that wants to show state before offering a
camera action. Returns BlazorNative.Core.CameraStatus.Captured to mean "usable"
(no capture ran) and BlazorNative.Core.CameraStatus.Unavailable when there is no
camera.
ValueTask<CameraStatus> CheckAvailabilityAsync(CancellationToken ct = null)