UNPKG

cordova-plugin-audioinput

Version:

Audio input capture plugin for Cordova and Capacitor - real-time microphone access with streaming and file recording support

523 lines 15 kB
{ "api": { "name": "AudioInputPlugin", "slug": "audioinputplugin", "docs": "Audio input plugin for Capacitor\nProvides real-time audio capture with support for streaming and file recording", "tags": [], "methods": [ { "name": "initialize", "signature": "(options: AudioInputOptions) => Promise<void>", "parameters": [ { "name": "options", "docs": "Configuration options for audio capture", "type": "AudioInputOptions" } ], "returns": "Promise<void>", "tags": [ { "name": "param", "text": "options Configuration options for audio capture" }, { "name": "returns", "text": "Promise that resolves when initialization is complete" } ], "docs": "Initialize the audio input plugin", "complexTypes": [ "AudioInputOptions" ], "slug": "initialize" }, { "name": "checkMicrophonePermission", "signature": "() => Promise<{ granted: boolean; }>", "parameters": [], "returns": "Promise<{ granted: boolean; }>", "tags": [ { "name": "returns", "text": "Promise with permission status" } ], "docs": "Check if microphone permission has been granted", "complexTypes": [], "slug": "checkmicrophonepermission" }, { "name": "getMicrophonePermission", "signature": "() => Promise<{ granted: boolean; }>", "parameters": [], "returns": "Promise<{ granted: boolean; }>", "tags": [ { "name": "returns", "text": "Promise with permission result" } ], "docs": "Request microphone permission from the user", "complexTypes": [], "slug": "getmicrophonepermission" }, { "name": "start", "signature": "(options?: AudioInputOptions | undefined) => Promise<void>", "parameters": [ { "name": "options", "docs": "Configuration options for audio capture", "type": "AudioInputOptions | undefined" } ], "returns": "Promise<void>", "tags": [ { "name": "param", "text": "options Configuration options for audio capture" }, { "name": "returns", "text": "Promise that resolves when recording starts" } ], "docs": "Start audio capture", "complexTypes": [ "AudioInputOptions" ], "slug": "start" }, { "name": "stop", "signature": "() => Promise<{ fileUrl?: string; }>", "parameters": [], "returns": "Promise<{ fileUrl?: string | undefined; }>", "tags": [ { "name": "returns", "text": "Promise with file URL if recording to file, otherwise void" } ], "docs": "Stop audio capture", "complexTypes": [], "slug": "stop" }, { "name": "isCapturing", "signature": "() => Promise<{ capturing: boolean; }>", "parameters": [], "returns": "Promise<{ capturing: boolean; }>", "tags": [], "docs": "Check whether the plugin is currently capturing audio.", "complexTypes": [], "slug": "iscapturing" }, { "name": "getCfg", "signature": "() => Promise<AudioInputOptions>", "parameters": [], "returns": "Promise<AudioInputOptions>", "tags": [], "docs": "Get the currently active capture configuration.", "complexTypes": [ "AudioInputOptions" ], "slug": "getcfg" }, { "name": "addListener", "signature": "(eventName: 'audioData', listenerFunc: (event: AudioDataEvent) => void) => Promise<PluginListenerHandle>", "parameters": [ { "name": "eventName", "docs": "Name of the event to listen for", "type": "'audioData'" }, { "name": "listenerFunc", "docs": "Callback function to handle the event", "type": "(event: AudioDataEvent) => void" } ], "returns": "Promise<PluginListenerHandle>", "tags": [ { "name": "param", "text": "eventName Name of the event to listen for" }, { "name": "param", "text": "listenerFunc Callback function to handle the event" }, { "name": "returns", "text": "Promise with listener handle for removal" } ], "docs": "Add a listener for audio data events", "complexTypes": [ "PluginListenerHandle", "AudioDataEvent" ], "slug": "addlisteneraudiodata-" }, { "name": "addListener", "signature": "(eventName: 'audioError', listenerFunc: (event: AudioErrorEvent) => void) => Promise<PluginListenerHandle>", "parameters": [ { "name": "eventName", "docs": "Name of the event to listen for", "type": "'audioError'" }, { "name": "listenerFunc", "docs": "Callback function to handle the event", "type": "(event: AudioErrorEvent) => void" } ], "returns": "Promise<PluginListenerHandle>", "tags": [ { "name": "param", "text": "eventName Name of the event to listen for" }, { "name": "param", "text": "listenerFunc Callback function to handle the event" }, { "name": "returns", "text": "Promise with listener handle for removal" } ], "docs": "Add a listener for audio error events", "complexTypes": [ "PluginListenerHandle", "AudioErrorEvent" ], "slug": "addlisteneraudioerror-" }, { "name": "addListener", "signature": "(eventName: 'audioInputFinished', listenerFunc: (event: AudioFinishedEvent) => void) => Promise<PluginListenerHandle>", "parameters": [ { "name": "eventName", "docs": "Name of the event to listen for", "type": "'audioInputFinished'" }, { "name": "listenerFunc", "docs": "Callback function to handle the event", "type": "(event: AudioFinishedEvent) => void" } ], "returns": "Promise<PluginListenerHandle>", "tags": [ { "name": "param", "text": "eventName Name of the event to listen for" }, { "name": "param", "text": "listenerFunc Callback function to handle the event" }, { "name": "returns", "text": "Promise with listener handle for removal" } ], "docs": "Add a listener for recording finished events (when recording to file)", "complexTypes": [ "PluginListenerHandle", "AudioFinishedEvent" ], "slug": "addlisteneraudioinputfinished-" }, { "name": "addListener", "signature": "(eventName: 'stateChange', listenerFunc: (event: AudioStateEvent) => void) => Promise<PluginListenerHandle>", "parameters": [ { "name": "eventName", "docs": "", "type": "'stateChange'" }, { "name": "listenerFunc", "docs": "", "type": "(event: AudioStateEvent) => void" } ], "returns": "Promise<PluginListenerHandle>", "tags": [], "docs": "Add a listener for state changes.", "complexTypes": [ "PluginListenerHandle", "AudioStateEvent" ], "slug": "addlistenerstatechange-" }, { "name": "removeAllListeners", "signature": "() => Promise<void>", "parameters": [], "returns": "Promise<void>", "tags": [ { "name": "returns", "text": "Promise that resolves when listeners are removed" } ], "docs": "Remove all listeners for this plugin", "complexTypes": [], "slug": "removealllisteners" } ], "properties": [] }, "interfaces": [ { "name": "AudioInputOptions", "slug": "audioinputoptions", "docs": "Configuration options for audio input capture", "tags": [], "methods": [], "properties": [ { "name": "sampleRate", "tags": [ { "text": "44100", "name": "default" } ], "docs": "Sample rate in Hz (e.g., 44100, 48000)", "complexTypes": [], "type": "number | undefined" }, { "name": "bufferSize", "tags": [ { "text": "16384", "name": "default" } ], "docs": "Buffer size in bytes (should be power of 2, <= 16384)", "complexTypes": [], "type": "number | undefined" }, { "name": "channels", "tags": [ { "text": "1", "name": "default" } ], "docs": "Number of audio channels (1 = mono, 2 = stereo)", "complexTypes": [], "type": "number | undefined" }, { "name": "format", "tags": [ { "text": "'PCM_16BIT'", "name": "default" } ], "docs": "Audio format ('PCM_16BIT' or 'PCM_8BIT')", "complexTypes": [], "type": "'PCM_16BIT' | 'PCM_8BIT' | undefined" }, { "name": "normalize", "tags": [ { "text": "true", "name": "default" } ], "docs": "Whether to normalize audio data to -1.0 to 1.0 range", "complexTypes": [], "type": "boolean | undefined" }, { "name": "normalizationFactor", "tags": [ { "text": "32767.0", "name": "default" } ], "docs": "Normalization factor (audio data will be divided by this value)", "complexTypes": [], "type": "number | undefined" }, { "name": "audioSourceType", "tags": [ { "text": "0", "name": "default" } ], "docs": "Audio source type\n- 0: DEFAULT\n- 1: MIC (Android only)\n- 5: CAMCORDER\n- 6: VOICE_RECOGNITION (Android only)\n- 7: VOICE_COMMUNICATION\n- 9: UNPROCESSED", "complexTypes": [], "type": "number | undefined" }, { "name": "fileUrl", "tags": [], "docs": "File URL to save recording (file://... format)\nIf set, audio data events will not be fired during recording.\nInstead, audioInputFinished event will fire when recording stops.", "complexTypes": [], "type": "string | undefined" } ] }, { "name": "PluginListenerHandle", "slug": "pluginlistenerhandle", "docs": "", "tags": [], "methods": [], "properties": [ { "name": "remove", "tags": [], "docs": "", "complexTypes": [], "type": "() => Promise<void>" } ] }, { "name": "AudioDataEvent", "slug": "audiodataevent", "docs": "Audio data event containing PCM samples", "tags": [], "methods": [], "properties": [ { "name": "data", "tags": [], "docs": "Array of audio samples\n- Int16Array if normalize=false\n- Float32Array if normalize=true (values -1.0 to 1.0)", "complexTypes": [], "type": "number[]" }, { "name": "sampleRate", "tags": [], "docs": "Metadata describing the emitted chunk.", "complexTypes": [], "type": "number | undefined" }, { "name": "channels", "tags": [], "docs": "", "complexTypes": [], "type": "number | undefined" }, { "name": "format", "tags": [], "docs": "", "complexTypes": [], "type": "'PCM_16BIT' | 'PCM_8BIT' | undefined" }, { "name": "timestamp", "tags": [], "docs": "", "complexTypes": [], "type": "number | undefined" } ] }, { "name": "AudioErrorEvent", "slug": "audioerrorevent", "docs": "Audio error event", "tags": [], "methods": [], "properties": [ { "name": "message", "tags": [], "docs": "Error message", "complexTypes": [], "type": "string" }, { "name": "code", "tags": [], "docs": "Optional machine-friendly error code.", "complexTypes": [], "type": "string | undefined" } ] }, { "name": "AudioFinishedEvent", "slug": "audiofinishedevent", "docs": "Recording finished event (when recording to file)", "tags": [], "methods": [], "properties": [ { "name": "fileUrl", "tags": [], "docs": "File URL where audio was saved", "complexTypes": [], "type": "string" }, { "name": "timestamp", "tags": [], "docs": "Unix timestamp (ms) when the finished event was emitted.", "complexTypes": [], "type": "number | undefined" } ] }, { "name": "AudioStateEvent", "slug": "audiostateevent", "docs": "Capture state change event.", "tags": [], "methods": [], "properties": [ { "name": "state", "tags": [], "docs": "", "complexTypes": [], "type": "'error' | 'idle' | 'capturing' | 'stopped'" }, { "name": "message", "tags": [], "docs": "", "complexTypes": [], "type": "string | undefined" }, { "name": "timestamp", "tags": [], "docs": "", "complexTypes": [], "type": "number | undefined" } ] } ], "enums": [], "typeAliases": [], "pluginConfigs": [] }