CameraViewer
The device camera as a live preview plus still-photo capture. All methods are static — there is
one camera session, no instances. takePhoto() returns a File (a host buffer
handle), so a shot can go straight into a texture (Texture2D.load(file)), an upload
(FormData), or the share sheet (share(file)).
At a glance
await CameraViewer.open() // asks permission, starts the back-camera preview
const photo = await CameraViewer.takePhoto()
CameraViewer.close()
share(photo, 'My shot')API
CameraViewer.open(facingMode?: 'front' | 'back'): Promise<void> // default 'back'
CameraViewer.setFacingMode(facingMode: 'front' | 'back'): void // switch while open
CameraViewer.takePhoto(): Promise<File> // host-encoded still image
CameraViewer.close(): void // stop preview, release cameraopen() first requests camera permission (the same engine-level request QRScanner uses), then
starts the live preview. The promise rejects if permission is denied or the camera can't start —
handle it.
Note
lifecycle — the camera stays claimed until close(). Always close when leaving the
screen (onClose), or the camera (and its OS indicator) stays on.
See also
- Files & share —
share()a captured photo;openFilePickeras the non-camera way to get an image - Networking — the
Filehandle and uploading viaFormData