AVCaptureSession: runtimeerror event
The runtimeerror event fires when an error occurs as the session starts capturing or while it's capturing.
Syntax
session.addEventListener('runtimeerror', (event) => { })Event object
AVCaptureSessionRuntimeErrorEvent, with one extra field:
The error the system gave, an NSError: message is the system's description, in the system language; domain and code are the system's error domain and code.
target is the session. Not cancelable; preventDefault() has no effect.
When it fires
- When
startRunning()fails to start the session. The Promise fromstartRunning()still fulfills, andisRunningisfalse. - When an error occurs while capturing and the system stops the session.
stopfires afterward. - The callback runs on the turn after the error.
Whether this event actually fires, and in which situations errors occur, are not verified on a device.
Examples
js
const session = new AVCaptureSession();
session.addEventListener('runtimeerror', (e) => {
console.log('Capture error', e.error.domain, e.error.code, e.error.message);
});Effect (not verified on a device): on an error, prints the error domain, the error code, and the system's description.
Corresponding iOS API
The notification AVCaptureSessionRuntimeErrorNotification. userInfo[AVCaptureSessionErrorKey] is e.error.
See also
startRunning()stop: capturing stopped