UNPKG

tauri-plugin-mic-recorder-api

Version:

Supports recording audio using a microphone and saving the recorded data as a file.

44 lines (40 loc) 976 B
'use strict'; var core = require('@tauri-apps/api/core'); const COMMAND = { START_RECORDING: "plugin:mic-recorder|start_recording", STOP_RECORDING: "plugin:mic-recorder|stop_recording", }; /** * Starts recording audio. * * @example * ``` * import { startRecording } from 'tauri-plugin-mic-recorder-api'; * * startRecording().then(() => { * console.log("Recording started"); * }); * ``` */ const startRecording = () => { return core.invoke(COMMAND.START_RECORDING); }; /** * Stops recording audio. * * @returns Returns the path where the recording file is stored. * * @example * ``` * import { stopRecording } from 'tauri-plugin-mic-recorder-api'; * * const savePath = await stopRecording(); * console.log("Recording saved at:", savePath); * ``` */ const stopRecording = () => { return core.invoke(COMMAND.STOP_RECORDING); }; exports.COMMAND = COMMAND; exports.startRecording = startRecording; exports.stopRecording = stopRecording;