@independo/capacitor-voice-recorder
Version:
Capacitor plugin for voice recording
48 lines (47 loc) • 2.6 kB
TypeScript
import type { ResponseFormat } from '../core/response-format';
import type { CurrentRecordingStatus, GenericResponse, RecordingData, RecordingOptions } from '../definitions';
/** Platform abstraction used by the service layer. */
export interface VoiceRecorderPlatform {
/** Checks whether the device can record audio. */
canDeviceVoiceRecord(): Promise<GenericResponse>;
/** Returns whether microphone permission is currently granted. */
hasAudioRecordingPermission(): Promise<GenericResponse>;
/** Requests microphone permission from the user. */
requestAudioRecordingPermission(): Promise<GenericResponse>;
/** Starts a recording session. */
startRecording(options?: RecordingOptions): Promise<GenericResponse>;
/** Stops the current recording session and returns the payload. */
stopRecording(): Promise<RecordingData>;
/** Pauses the recording session when supported. */
pauseRecording(): Promise<GenericResponse>;
/** Resumes a paused recording session when supported. */
resumeRecording(): Promise<GenericResponse>;
/** Returns the current recording state. */
getCurrentStatus(): Promise<CurrentRecordingStatus>;
}
/** Orchestrates platform calls and normalizes responses when requested. */
export declare class VoiceRecorderService {
/** Selected response format derived from plugin config. */
private readonly responseFormat;
/** Platform adapter that performs the actual recording work. */
private readonly platform;
constructor(platform: VoiceRecorderPlatform, responseFormat: ResponseFormat);
/** Checks whether the device can record audio. */
canDeviceVoiceRecord(): Promise<GenericResponse>;
/** Returns whether microphone permission is currently granted. */
hasAudioRecordingPermission(): Promise<GenericResponse>;
/** Requests microphone permission from the user. */
requestAudioRecordingPermission(): Promise<GenericResponse>;
/** Starts a recording session. */
startRecording(options?: RecordingOptions): Promise<GenericResponse>;
/** Stops the recording session and formats the payload if needed. */
stopRecording(): Promise<RecordingData>;
/** Pauses the recording session when supported. */
pauseRecording(): Promise<GenericResponse>;
/** Resumes a paused recording session when supported. */
resumeRecording(): Promise<GenericResponse>;
/** Returns the current recording state. */
getCurrentStatus(): Promise<CurrentRecordingStatus>;
/** Wraps calls to apply canonical error codes when requested. */
private execute;
}