npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

native-mic-capacitor

v0.1.1

Published

Get native stream of your microphone

Readme

native-mic-capacitor

Get native stream of your microphone

Install

npm install native-mic-capacitor
npx cap sync

API

isAvailable()

isAvailable() => Promise<{ available: boolean; reason?: string; }>

Returns: Promise<{ available: boolean; reason?: string; }>


checkPermissions()

checkPermissions() => Promise<{ microphone: MicPermissionState; }>

Returns: Promise<{ microphone: MicPermissionState; }>


requestPermissions()

requestPermissions() => Promise<{ microphone: MicPermissionState; }>

Returns: Promise<{ microphone: MicPermissionState; }>


getDevices()

getDevices() => Promise<{ inputs: MicDevice[]; selectedInputId?: string; }>

Returns: Promise<{ inputs: MicDevice[]; selectedInputId?: string; }>


setPreferredInput(...)

setPreferredInput(options: { inputId: string | null; }) => Promise<void>

| Param | Type | | ------------- | ----------------------------------------- | | options | { inputId: string | null; } |


setOutputRoute(...)

setOutputRoute(options: { route: OutputRoute; }) => Promise<void>

| Param | Type | | ------------- | --------------------------------------------------------------- | | options | { route: OutputRoute; } |


startCapture(...)

startCapture(options: StartCaptureOptions) => Promise<StartCaptureResult>

| Param | Type | | ------------- | ------------------------------------------------------------------- | | options | StartCaptureOptions |

Returns: Promise<StartCaptureResult>


stopCapture(...)

stopCapture(options: StopCaptureOptions) => Promise<StopCaptureResult>

| Param | Type | | ------------- | ----------------------------------------------------------------- | | options | StopCaptureOptions |

Returns: Promise<StopCaptureResult>


setMicEnabled(...)

setMicEnabled(options: { captureId: string; enabled: boolean; }) => Promise<void>

| Param | Type | | ------------- | ----------------------------------------------------- | | options | { captureId: string; enabled: boolean; } |


getState()

getState() => Promise<{ state: 'idle' | 'running' | 'paused'; }>

Returns: Promise<{ state: 'idle' | 'running' | 'paused'; }>


getDiagnostics()

getDiagnostics() => Promise<Record<string, unknown>>

Returns: Promise<Record<string, unknown>>


webrtcIsAvailable()

webrtcIsAvailable() => Promise<{ available: boolean; reason?: string; }>

Returns: Promise<{ available: boolean; reason?: string; }>


webrtcConnect(...)

webrtcConnect(options: NativeWebRTCConnectOptions) => Promise<NativeWebRTCConnectResult>

| Param | Type | | ------------- | --------------------------------------------------------------------------------- | | options | NativeWebRTCConnectOptions |

Returns: Promise<NativeWebRTCConnectResult>


webrtcDisconnect(...)

webrtcDisconnect(options: { connectionId: string; reason?: string; }) => Promise<void>

| Param | Type | | ------------- | ------------------------------------------------------- | | options | { connectionId: string; reason?: string; } |


webrtcForceReset(...)

webrtcForceReset(options?: { reason?: string | undefined; } | undefined) => Promise<void>

| Param | Type | | ------------- | --------------------------------- | | options | { reason?: string; } |


webrtcSendDataMessage(...)

webrtcSendDataMessage(options: { connectionId: string; data: string; }) => Promise<void>

| Param | Type | | ------------- | ---------------------------------------------------- | | options | { connectionId: string; data: string; } |


webrtcSetMicEnabled(...)

webrtcSetMicEnabled(options: { connectionId: string; enabled: boolean; }) => Promise<void>

| Param | Type | | ------------- | -------------------------------------------------------- | | options | { connectionId: string; enabled: boolean; } |


webrtcSetRemoteAudioEnabled(...)

webrtcSetRemoteAudioEnabled(options: { connectionId: string; enabled: boolean; }) => Promise<void>

| Param | Type | | ------------- | -------------------------------------------------------- | | options | { connectionId: string; enabled: boolean; } |


webrtcSetPreferredInput(...)

webrtcSetPreferredInput(options: { connectionId: string; inputId: string | null; }) => Promise<void>

| Param | Type | | ------------- | --------------------------------------------------------------- | | options | { connectionId: string; inputId: string | null; } |


webrtcSetOutputRoute(...)

webrtcSetOutputRoute(options: { connectionId: string; route: OutputRoute; }) => Promise<void>

| Param | Type | | ------------- | ------------------------------------------------------------------------------------- | | options | { connectionId: string; route: OutputRoute; } |


webrtcGetState(...)

webrtcGetState(options: { connectionId: string; }) => Promise<NativeWebRTCStateResult>

| Param | Type | | ------------- | -------------------------------------- | | options | { connectionId: string; } |

Returns: Promise<NativeWebRTCStateResult>


webrtcGetDiagnostics(...)

webrtcGetDiagnostics(options: { connectionId: string; }) => Promise<Record<string, unknown>>

| Param | Type | | ------------- | -------------------------------------- | | options | { connectionId: string; } |

Returns: Promise<Record<string, unknown>>


addListener('micStateChanged', ...)

addListener(eventName: 'micStateChanged', listenerFunc: (event: MicStateChangedEvent) => void) => Promise<PluginListenerHandle>

| Param | Type | | ------------------ | ----------------------------------------------------------------------------------------- | | eventName | 'micStateChanged' | | listenerFunc | (event: MicStateChangedEvent) => void |

Returns: Promise<PluginListenerHandle>


addListener('micPcmChunk', ...)

addListener(eventName: 'micPcmChunk', listenerFunc: (event: MicPcmChunkEvent) => void) => Promise<PluginListenerHandle>

| Param | Type | | ------------------ | --------------------------------------------------------------------------------- | | eventName | 'micPcmChunk' | | listenerFunc | (event: MicPcmChunkEvent) => void |

Returns: Promise<PluginListenerHandle>


addListener('micAudioLevel', ...)

addListener(eventName: 'micAudioLevel', listenerFunc: (event: MicAudioLevelEvent) => void) => Promise<PluginListenerHandle>

| Param | Type | | ------------------ | ------------------------------------------------------------------------------------- | | eventName | 'micAudioLevel' | | listenerFunc | (event: MicAudioLevelEvent) => void |

Returns: Promise<PluginListenerHandle>


addListener('micRouteChanged', ...)

addListener(eventName: 'micRouteChanged', listenerFunc: (event: MicRouteChangedEvent) => void) => Promise<PluginListenerHandle>

| Param | Type | | ------------------ | ----------------------------------------------------------------------------------------- | | eventName | 'micRouteChanged' | | listenerFunc | (event: MicRouteChangedEvent) => void |

Returns: Promise<PluginListenerHandle>


addListener('micInterruption', ...)

addListener(eventName: 'micInterruption', listenerFunc: (event: MicInterruptionEvent) => void) => Promise<PluginListenerHandle>

| Param | Type | | ------------------ | ----------------------------------------------------------------------------------------- | | eventName | 'micInterruption' | | listenerFunc | (event: MicInterruptionEvent) => void |

Returns: Promise<PluginListenerHandle>


addListener('micError', ...)

addListener(eventName: 'micError', listenerFunc: (event: MicErrorEvent) => void) => Promise<PluginListenerHandle>

| Param | Type | | ------------------ | --------------------------------------------------------------------------- | | eventName | 'micError' | | listenerFunc | (event: MicErrorEvent) => void |

Returns: Promise<PluginListenerHandle>


addListener('webrtcStateChanged', ...)

addListener(eventName: 'webrtcStateChanged', listenerFunc: (event: NativeWebRTCStateChangedEvent) => void) => Promise<PluginListenerHandle>

| Param | Type | | ------------------ | ----------------------------------------------------------------------------------------------------------- | | eventName | 'webrtcStateChanged' | | listenerFunc | (event: NativeWebRTCStateChangedEvent) => void |

Returns: Promise<PluginListenerHandle>


addListener('webrtcDataMessage', ...)

addListener(eventName: 'webrtcDataMessage', listenerFunc: (event: NativeWebRTCDataMessageEvent) => void) => Promise<PluginListenerHandle>

| Param | Type | | ------------------ | --------------------------------------------------------------------------------------------------------- | | eventName | 'webrtcDataMessage' | | listenerFunc | (event: NativeWebRTCDataMessageEvent) => void |

Returns: Promise<PluginListenerHandle>


addListener('webrtcTrackStarted', ...)

addListener(eventName: 'webrtcTrackStarted', listenerFunc: (event: NativeWebRTCTrackEvent) => void) => Promise<PluginListenerHandle>

| Param | Type | | ------------------ | --------------------------------------------------------------------------------------------- | | eventName | 'webrtcTrackStarted' | | listenerFunc | (event: NativeWebRTCTrackEvent) => void |

Returns: Promise<PluginListenerHandle>


addListener('webrtcTrackStopped', ...)

addListener(eventName: 'webrtcTrackStopped', listenerFunc: (event: NativeWebRTCTrackEvent) => void) => Promise<PluginListenerHandle>

| Param | Type | | ------------------ | --------------------------------------------------------------------------------------------- | | eventName | 'webrtcTrackStopped' | | listenerFunc | (event: NativeWebRTCTrackEvent) => void |

Returns: Promise<PluginListenerHandle>


addListener('webrtcLocalAudioLevel', ...)

addListener(eventName: 'webrtcLocalAudioLevel', listenerFunc: (event: NativeWebRTCAudioLevelEvent) => void) => Promise<PluginListenerHandle>

| Param | Type | | ------------------ | ------------------------------------------------------------------------------------------------------- | | eventName | 'webrtcLocalAudioLevel' | | listenerFunc | (event: NativeWebRTCAudioLevelEvent) => void |

Returns: Promise<PluginListenerHandle>


addListener('webrtcRemoteAudioLevel', ...)

addListener(eventName: 'webrtcRemoteAudioLevel', listenerFunc: (event: NativeWebRTCAudioLevelEvent) => void) => Promise<PluginListenerHandle>

| Param | Type | | ------------------ | ------------------------------------------------------------------------------------------------------- | | eventName | 'webrtcRemoteAudioLevel' | | listenerFunc | (event: NativeWebRTCAudioLevelEvent) => void |

Returns: Promise<PluginListenerHandle>


addListener('webrtcError', ...)

addListener(eventName: 'webrtcError', listenerFunc: (event: NativeWebRTCErrorEvent) => void) => Promise<PluginListenerHandle>

| Param | Type | | ------------------ | --------------------------------------------------------------------------------------------- | | eventName | 'webrtcError' | | listenerFunc | (event: NativeWebRTCErrorEvent) => void |

Returns: Promise<PluginListenerHandle>


removeAllListeners()

removeAllListeners() => Promise<void>

Interfaces

MicDevice

| Prop | Type | | --------------- | ----------------------------------------------------------------------- | | id | string | | label | string | | type | 'built_in' | 'wired' | 'bluetooth' | 'usb' | 'unknown' | | isDefault | boolean |

StartCaptureResult

| Prop | Type | | --------------------------- | ------------------- | | captureId | string | | actualInputSampleRate | number | | actualInputChannels | number | | chunkMs | number |

StartCaptureOptions

| Prop | Type | | -------------------------- | --------------------------------------------------- | | profile | MicProfile | | mode | SessionMode | | outputStreams | OutputStream[] | | chunkMs | number | | emitAudioLevel | boolean | | audioLevelIntervalMs | number | | voiceProcessing | boolean | | preferredInputId | string | | outputRoute | OutputRoute |

StopCaptureResult

| Prop | Type | | ----------------------- | ------------------- | | captureId | string | | totalFramesIn | number | | totalFramesOut16k | number | | totalFramesOut48k | number | | durationMs | number |

StopCaptureOptions

| Prop | Type | | -------------------- | ------------------- | | captureId | string | | flushTimeoutMs | number |

NativeWebRTCConnectResult

| Prop | Type | | ------------------------- | --------------------------------------------------------------- | | connectionId | string | | pcId | string | | selectedInputId | string | | selectedOutputRoute | OutputRoute | | state | NativeWebRTCState |

NativeWebRTCConnectOptions

| Prop | Type | | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | | connectionId | string | | webrtcRequest | WebRTCRequestInfo | | iceConfig | { iceServers?: RTCIceServerLike[]; } | | waitForICEGathering | boolean | | audioCodec | string | null | | videoCodec | string | null | | media | { voiceProcessing?: boolean; startMicEnabled?: boolean; preferredInputId?: string; outputRoute?: OutputRoute; } | | reconnect | { enabled?: boolean; maxAttempts?: number; backoffMs?: number; } |

WebRTCRequestInfo

| Prop | Type | | ----------------- | ---------------------------------------------------------------- | | endpoint | string | | headers | Record<string, string> | | requestData | Record<string, unknown> | | timeoutMs | number |

NativeWebRTCStateResult

| Prop | Type | | ------------------------ | --------------------------------------------------------------- | | connectionId | string | | state | NativeWebRTCState | | pcId | string | | iceConnectionState | string | | signalingState | string |

PluginListenerHandle

| Prop | Type | | ------------ | ----------------------------------------- | | remove | () => Promise<void> |

MicStateChangedEvent

| Prop | Type | | --------------- | -------------------------------------------- | | captureId | string | | state | 'idle' | 'running' | 'paused' | | reason | string |

MicPcmChunkEvent

| Prop | Type | | ---------------- | ----------------------------------------------------- | | captureId | string | | stream | OutputStream | | sampleRate | 16000 | 48000 | | channels | 1 | | frames | number | | seq | number | | ptsMs | number | | dataBase64 | string | | final | boolean |

MicAudioLevelEvent

| Prop | Type | | --------------- | -------------------- | | captureId | string | | rms | number | | peak | number | | dbfs | number | | vad | boolean | | ptsMs | number |

MicRouteChangedEvent

| Prop | Type | | --------------------- | ------------------- | | captureId | string | | reason | string | | selectedInputId | string |

MicInterruptionEvent

| Prop | Type | | ------------------ | ------------------------------- | | captureId | string | | phase | 'began' | 'ended' | | shouldResume | boolean | | reason | string |

MicErrorEvent

| Prop | Type | | ----------------- | -------------------- | | captureId | string | | code | string | | message | string | | recoverable | boolean | | nativeCode | string |

NativeWebRTCStateChangedEvent

| Prop | Type | | ------------------ | --------------------------------------------------------------- | | connectionId | string | | state | NativeWebRTCState | | reason | string | | pcId | string |

NativeWebRTCDataMessageEvent

| Prop | Type | | ------------------ | ------------------- | | connectionId | string | | data | string |

NativeWebRTCTrackEvent

| Prop | Type | | ------------------ | ------------------------------------------------ | | connectionId | string | | kind | 'audio' | 'video' | 'screenVideo' | | source | 'remote' | 'local' |

NativeWebRTCAudioLevelEvent

| Prop | Type | | ------------------ | ------------------- | | connectionId | string | | level | number |

NativeWebRTCErrorEvent

| Prop | Type | | ------------------ | ----------------------------------------------------------------------- | | connectionId | string | | code | NativeWebRTCErrorCode | | message | string | | recoverable | boolean | | nativeCode | string |

Type Aliases

MicPermissionState

'prompt' | 'granted' | 'denied'

OutputRoute

'system' | 'speaker' | 'receiver'

MicProfile

'waveform' | 'pipecat'

SessionMode

'measurement' | 'voice_chat'

OutputStream

'pcm16k_s16le' | 'pcm48k_s16le'

Record

Construct a type with a set of properties K of type T

{ [P in K]: T; }

NativeWebRTCState

'idle' | 'initializing' | 'connecting' | 'connected' | 'ready' | 'reconnecting' | 'disconnecting' | 'error'

RTCIceServerLike

{ urls: string | string[]; username?: string; credential?: string; }

NativeWebRTCErrorCode

'E_WEBRTC_UNAVAILABLE' | 'E_PC_CREATE_FAILED' | 'E_NEGOTIATION_FAILED' | 'E_ICE_FAILED' | 'E_DATA_CHANNEL_FAILED' | 'E_ALREADY_RUNNING' | 'E_NOT_RUNNING' | 'E_INVALID_ARGUMENT' | 'E_INTERNAL'