AVCaptureSession: isInterrupted property
The isInterrupted property indicates whether the session is currently interrupted by the system. When a call comes in, the app goes to the background, or another app uses the camera, the system interrupts the session and the session temporarily stops capturing.
Value
A boolean.
| Value | Meaning |
|---|---|
true | Interrupted; temporarily not capturing |
false | Not interrupted |
- Read-only. Assigning to it throws
TypeError. falsefor a new session (verified by testing).interruptfires when it becomestrue, andinterruptendfires when it goes back tofalse.- Situations where it actually becomes
trueare not verified on a device.
Examples
js
const session = new AVCaptureSession();
session.addEventListener('interruptend', () => {
console.log('Interruption ended', session.isInterrupted);
});Effect (not verified on a device): after the session has been interrupted, prints Interruption ended false when the interruption ends.
Corresponding iOS API
AVCaptureSession.interrupted (the getter is isInterrupted). In ObjC you learn that it changed through key-value observing or notifications; here, listen for the interrupt and interruptend events.
See also
interrupt: the session was interrupted, with the reasoninterruptend: the interruption ended- When the session is interrupted