Here's a sample code to check if an Audiotrack created with getUserMedia
is playing or not using the Web Audio API
in JavaScript:
index.tsx560 chars17 lines
This code creates an AudioContext
, connects the MediaStreamSource
from the user media to the destination
node of the context, and then checks every 100ms if the state
of the context is 'running'
(which indicates that the Audiotrack is playing). If the Audiotrack
is not playing anymore, the interval is stopped with clearInterval
.
gistlibby LogSnag