UNPKG

@independo/capacitor-voice-recorder

Version:
47 lines 2.02 kB
import { Capacitor, WebPlugin } from '@capacitor/core'; import { VoiceRecorderWebAdapter } from './adapters/VoiceRecorderWebAdapter'; import { getResponseFormatFromConfig } from './core/response-format'; import { VoiceRecorderService } from './service/VoiceRecorderService'; /** Web implementation of the VoiceRecorder Capacitor plugin. */ export class VoiceRecorderWeb extends WebPlugin { constructor() { var _a, _b; super(); const pluginConfig = (_b = (_a = Capacitor === null || Capacitor === void 0 ? void 0 : Capacitor.config) === null || _a === void 0 ? void 0 : _a.plugins) === null || _b === void 0 ? void 0 : _b.VoiceRecorder; const responseFormat = getResponseFormatFromConfig(pluginConfig); this.service = new VoiceRecorderService(new VoiceRecorderWebAdapter(), responseFormat); } /** Checks whether the browser can record audio. */ canDeviceVoiceRecord() { return this.service.canDeviceVoiceRecord(); } /** Returns whether microphone permission is currently granted. */ hasAudioRecordingPermission() { return this.service.hasAudioRecordingPermission(); } /** Requests microphone permission from the user. */ requestAudioRecordingPermission() { return this.service.requestAudioRecordingPermission(); } /** Starts a recording session. */ startRecording(options) { return this.service.startRecording(options); } /** Stops the current recording session and returns the payload. */ stopRecording() { return this.service.stopRecording(); } /** Pauses the recording session when supported. */ pauseRecording() { return this.service.pauseRecording(); } /** Resumes a paused recording session when supported. */ resumeRecording() { return this.service.resumeRecording(); } /** Returns the current recording state. */ getCurrentStatus() { return this.service.getCurrentStatus(); } } //# sourceMappingURL=web.js.map