Radical
Reference

Video stream API

Scoped camera preview, controls, and QR detection.

Native enablement is internalPlugins.videoStream. The dependency is @capgo/camera-preview@8.14.2. pluginOptions.VideoStream.usageDescription is required.

Session contract

startVideoStream(options) returns Effect<VideoStreamSession, VideoStreamError, Bridge | BrowserVideoStream | Scope>. The caller's scope owns preview presentation, camera resources, and listeners. Closing the scope stops the session.

OptionTypeDefault
viewfinderHTMLElement, requiredMounted element with nonzero size.
facing"front" or "rear""rear"
onDetectCallback receiving a stringOmitted. Receives QR values.

The session exposes Effect values info and switchCamera, plus setZoom(level) and setTorch(enabled) returning Effects. Controls require Bridge.

videoStreamLive(effect) provides BrowserVideoStreamLive. BrowserVideoStream is the injectable browser service.

Status fields

VideoStreamInfoSchema validates VideoStreamInfo:

FieldType
facing"front" or "rear"
zoomOptional { min, max, current }, all finite numbers
torchBoolean
torchAvailableBoolean
frameRateOptional finite number
detectionAvailableBoolean
CapabilityAndroidiOSBrowser
PreviewBehind transparent WebView cut-outBehind transparent WebView cut-outgetUserMedia
QR detectionNative preview detectorNative preview detectorRequires BarcodeDetector
Video file recordingNot exposedNot exposedNot exposed

Errors and hook

ErrorMeaning
BridgeErrorTransport or validation failure; native sessions require listener support
PermissionDeniedNative cameraPermissionDenied
UnavailableIncludes missing mounted viewfinder in the hook

useVideoStream({ viewfinder, facing?, onDetect? }) accepts a React ref rather than an element. It returns start, stop, switchCamera, setZoom, setTorch, running, loading, value, and error. Unmount and provider replacement release the session.

Source: video implementation.

On this page