Skip to main content
cngx-src documentation

createAutoplayGate

Functioncommon/audiov0.1.0

projects/common/audio/autoplay-gate/autoplay-gate.ts

Description#

Create the autoplay gate: a one-shot latch that flips armed to true on the first pointerdown / keydown / touchstart and then removes its own listeners. The engine consults armed() before resuming the shared AudioContext, honouring the browser autoplay policy without a permission prompt.

Pure factory — takes its target and destroyRef as arguments rather than calling inject(), so it composes inside the engine's injection context yet stays testable with a fake target. No DI token: the gate has no independent swap consumer (severity ladder concern: over-abstraction), so it ships token-less and the engine owns it.

Signature#

createAutoplayGate(deps)

Parameters#

@paramdeps

Returns#

CngxAutoplayGate