UNPKG

@klever-one/web-sdk

Version:

Web SDK for integrating real-time room management and streaming functionality into web applications

55 lines (54 loc) 1.77 kB
export type RecorderStatus = "idle" | "recording" | "stopped"; export interface RecorderState { status: RecorderStatus; mediaBlobUrl: string | null; } export interface RecorderEventData { status?: RecorderStatus; mediaBlobUrl?: string | null; audioBlob?: Blob | null; error?: Error; errorType?: "permission" | "technical" | "system"; } export declare class RecorderService { private static instance; private audioContext; private mediaStream; private mediaStreamSource; private audioWorkletNode; private audioData; private mediaRecorder; private recordedChunks; private useMediaRecorderFallback; private analyserNode; private audioLevelInterval; private _status; private _mediaBlobUrl; private statusListeners; private mediaBlobUrlListeners; private stateListeners; private constructor(); static getInstance(): RecorderService; static hasInstance(): boolean; get status(): RecorderStatus; get mediaBlobUrl(): string | null; get state(): RecorderState; private setStatus; private setMediaBlobUrl; private notifyStateListeners; private emitStateChange; addStatusListener(listener: (status: RecorderStatus) => void): () => void; addMediaBlobUrlListener(listener: (url: string | null) => void): () => void; addStateListener(listener: (state: RecorderState) => void): () => void; startRecording(): Promise<void>; private setupAudioWorklet; private setupMediaRecorder; stopRecording(): Promise<Blob | null>; clearBlobUrl(): void; reset(): void; private encodeWAV; private flattenArray; private encodeWavBuffer; private setupAudioLevelMonitoring; private stopMediaRecorderRecording; }