UNPKG

capacitor-audio-engine

Version:

High-quality audio recording Capacitor plugin with native iOS & Android support. Features pause/resume, microphone management, real-time monitoring, audio trimming, and comprehensive mobile audio recording capabilities.

204 lines (203 loc) 8.77 kB
import type { PluginListenerHandle } from '@capacitor/core'; import { WebPlugin } from '@capacitor/core'; import type { CapacitorAudioEnginePlugin, AudioEventName, AudioFileInfo, AudioEventMap, PreloadTracksOptions, PreloadTracksResult, PlaybackInfo, SeekTrackOptions, SkipToIndexTrackOptions, WaveLevelConfigurationResult, PermissionRequestOptions, PermissionStatusResults, RecordingStatusInfo, TrimTrackOptions, MicAvailableResult } from './definitions'; declare global { interface BlobEventInit extends EventInit { data: Blob; } interface BlobEvent extends Event { readonly data: Blob; } } export declare class CapacitorAudioEngineWeb extends WebPlugin implements CapacitorAudioEnginePlugin { /** * Reset the current live recording session. * @platform web Not supported */ resetRecording(): Promise<void>; /** * Check permission status with detailed information for each permission type. * @returns Promise that resolves with detailed permission status including granular information * @platform web Returns unsupported status for all permissions */ checkPermissions(): Promise<PermissionStatusResults>; /** * Check microphone permission status with detailed information. * @returns Promise that resolves with detailed microphone permission status * @platform web Returns unsupported status */ checkPermissionMicrophone(): Promise<PermissionStatusResults>; /** * Check notification permission status with detailed information. * @returns Promise that resolves with detailed notification permission status * @platform web Returns unsupported status */ checkPermissionNotifications(): Promise<PermissionStatusResults>; /** * Request permissions with detailed options and status information. * @param options - Permission request options * @returns Promise that resolves with detailed permission status * @platform web Returns unsupported status for all permissions */ requestPermissions(_options?: PermissionRequestOptions): Promise<PermissionStatusResults>; /** * Request microphone permission only. * @param options - Permission request options * @returns Promise that resolves with microphone permission status * @platform web Returns unsupported status */ requestPermissionMicrophone(_options?: PermissionRequestOptions): Promise<PermissionStatusResults>; /** * Request notification permission only. * @param options - Permission request options * @returns Promise that resolves with notification permission status * @platform web Returns unsupported status */ requestPermissionNotifications(_options?: PermissionRequestOptions): Promise<PermissionStatusResults>; /** * Add a listener for recording events * @returns A promise that resolves with a handle to the listener * @platform web Not supported */ addListener<T extends AudioEventName>(eventName: T, callback: (event: AudioEventMap[T]) => void): Promise<PluginListenerHandle>; /** * Check if microphone is currently being used by another application. * @returns Promise that resolves with microphone status * @platform web Not supported */ isMicrophoneBusy(): Promise<never>; /** * Get list of available microphones (internal and external). * @returns Promise that resolves with available microphones * @platform web Not supported */ getAvailableMicrophones(): Promise<never>; /** * Switch between microphones while keeping recording active. * @param options - Switch microphone options * @returns Promise that resolves with switch result * @platform web Not supported */ switchMicrophone(options: { microphoneId: number; }): Promise<never>; /** * Remove all listeners * @returns Promise that resolves when all listeners are removed * @platform web Not supported */ removeAllListeners(): Promise<void>; /** * Configure waveform data generation settings with default values. * @returns Promise that resolves with configuration result * @platform web Not supported */ configureWaveform(options?: { EmissionInterval?: number; }): Promise<WaveLevelConfigurationResult>; /** * Destroy waveform configuration and clean up resources. * @returns Promise that resolves when waveform configuration is destroyed * @platform web Not supported */ destroyWaveform(): Promise<void>; /** * Preload audio tracks from URLs for individual playback * @param options - Preload options containing track URLs * @returns Promise that resolves with preload results for each track including load status, mimetype, duration, and file size * @platform web Not supported */ preloadTracks(options: PreloadTracksOptions): Promise<PreloadTracksResult>; /** * Start or resume playback of current track or specific preloaded track by URL * @param options - Optional playback options with URL to play specific preloaded track * @returns Promise that resolves when playback starts * @platform web Not supported */ playTrack(_options?: { url?: string; }): Promise<void>; /** * Pause audio playback for current track or specific preloaded track by URL * @param options - Optional pause options with URL to pause specific preloaded track * @returns Promise that resolves when playback is paused * @platform web Not supported */ pauseTrack(_options?: { url?: string; }): Promise<void>; /** * Resume audio playback from paused state for current track or specific preloaded track by URL * @param options - Optional resume options with URL to resume specific preloaded track * @returns Promise that resolves when playback resumes * @platform web Not supported */ resumeTrack(_options?: { url?: string; }): Promise<void>; /** * Stop audio playback and reset to beginning for current track or specific preloaded track by URL * @param options - Optional stop options with URL to stop specific preloaded track * @returns Promise that resolves when playback stops * @platform web Not supported */ stopTrack(_options?: { url?: string; }): Promise<void>; /** * Seek to specific position in current track or specific preloaded track by URL * @param options - Seek options with time in seconds and optional URL for specific preloaded track * @returns Promise that resolves when seek completes * @platform web Not supported */ seekTrack(_options: SeekTrackOptions): Promise<void>; /** * Skip to next track in playlist (simplified - no-op for single track playback) * @returns Promise that resolves when skip completes * @platform web Not supported */ skipToNext(): Promise<void>; /** * Skip to previous track in playlist (simplified - no-op for single track playback) * @returns Promise that resolves when skip completes * @platform web Not supported */ skipToPrevious(): Promise<void>; /** * Skip to specific track index in playlist (simplified - no-op for single track playback) * @param options - Options with target track index * @returns Promise that resolves when skip completes * @platform web Not supported */ skipToIndex(_options: SkipToIndexTrackOptions): Promise<void>; /** * Get current playback information * @returns Promise that resolves with current playback state * @platform web Not supported */ getPlaybackInfo(): Promise<PlaybackInfo>; /** * Destroy and reinitialize the playback manager * @returns Promise that resolves when playback manager is destroyed and reinitialized * @platform web No-op (browser handles cleanup automatically) */ destroyPlayback(): Promise<void>; /** * Navigate to the app's permission settings screen. * @returns Promise that resolves when navigation is initiated * @platform web Shows alert with instructions to manually open browser settings for permissions */ openSettings(): Promise<void>; startRecording(_options: { path: string; }): Promise<{ uri: string; }>; stopRecording(): Promise<AudioFileInfo>; pauseRecording(): Promise<void>; resumeRecording(): Promise<void>; getRecordingStatus(): Promise<RecordingStatusInfo>; trimAudio(_options: TrimTrackOptions): Promise<AudioFileInfo>; getAudioInfo(): Promise<AudioFileInfo>; micAvailable(): Promise<MicAvailableResult>; }