AVCaptureSession: isRunning property
The isRunning property indicates whether the session is capturing right now.
Value
A boolean.
| Value | Meaning |
|---|---|
true | Capturing: the camera is on and the metadata output is recognizing |
false | Not capturing |
- Read-only. Assigning to it throws
TypeError(verified by testing). falsefor a new session.trueafterstartRunning()fulfills, andfalseafterstopRunning()fulfills (verified by testing).startfires when it becomestrue, andstopfires when it becomesfalse.- Whether it changes when the session is interrupted (an incoming call, the app going to the background) is not verified on a device. For interruptions, check
isInterrupted.
Examples
js
const session = new AVCaptureSession();
console.log(session.isRunning);
session.addEventListener('start', () => console.log('Now', session.isRunning));Effect: first prints false. Later, when the session starts capturing, prints Now true.
Corresponding iOS API
AVCaptureSession.running (the getter is isRunning). In ObjC you learn that it changed through key-value observing; here, listen for the start and stop events.
See also
start,stopisInterrupted: whether the session is interrupted