AVCaptureSession() constructor
The AVCaptureSession() constructor creates a capture session. A session connects inputs (cameras) to outputs (the metadata output that recognizes codes, and the preview layer that shows the picture).
Syntax
new AVCaptureSession()Parameters
None.
Return value
A new AVCaptureSession. Each new gives a new object. A new session has:
inputsandoutputsas empty arrays.sessionPresetset to'high'.isRunningandisInterruptedset tofalse.
Creating a session needs no camera authorization and shows no alert.
Exceptions
TypeError
- Subclassing it:
class Mine extends AVCaptureSession {}throws atnew Mine(), with the messageIllegal constructor: Mine extends AVCaptureSession, but subclassing native classes is not supported yet.
Examples
js
const session = new AVCaptureSession();
console.log(session.sessionPreset, session.inputs.length, session.isRunning);Result: prints high 0 false.
Corresponding iOS API
[[AVCaptureSession alloc] init].
See also
addInput(): connect a cameraaddOutput(): add an output that recognizes codesstartRunning(): start capturing- Installing
@nacrejs/av-capture