Provides links&functions based on capacitor-voice-recorder
.
The AudioRecords
link serves as a container for link structures representing records inside deep.
The Sound
link represents recorded data as base64 string.
All links of type Sound can be played with left click.
capacitor-voice-recorder provides only MIME/type as audio prop and it gets stored as link.
All new links of type Sound will be parced with async handler inside Sound package using music-metadata npm library. Useful data will be stored as a prop links inside Sound link. Make sure to give permissions to Sound package with Join link.
import Recorder, { createContainer } from "@deep-foundation/capacitor-voice-recorder";
const containerLinkId = await createContainer(deep);
You can also create it manually inside your deepcase client. Open Insert menu, search for and then insert "AudioRecords" type link.
Call getAudioRecordingPermissions method of the Recorder to get audio recording and microphone usage permissions for your app.
const permissionSatus = await Recorder.getAudioRecordingPermissions();
Start recording audio and return the playback status.
const isrecording = await Recorder.startRecording();
Pause the ongoing recording and return the playback status.
const ispaused = await Recorder.pauseRecording();;
Resume the ongoing recording and return the playback status.
const isresumed = await Recorder.resumeRecording();
Stop the ongoing recording, upload the recorded sound, and return the recorded sound with info.
const { recordDataBase64, msDuration, mimeType } = await Recorder.stopRecording({
deep, // The DeepClient object
containerLinkId, // The ID of the container link
});
Download all existing records made by this recorder as array of IRecord
records.
const records = Recorder.downloadRecords(deep);
import { WithVoiceRecorder, VoiceRecorder, useContainer, useRecordingCycle, useRecordingStatus } from "@deep-foundation/capacitor-voice-recorder";
<VoiceRecorder deep={deep} />
You will see basic ui with all package functionality.
Alternatively you can use WithVoiceRecorder Component like that:
<WithVoiceRecorder deep={yourDeepInstance} containerLinkId={yourContainerLinkId}>
<VoiceRecorder />
</WithVoiceRecorder>
useContainer hook to get existing or create a new container link ID.
const containerLinkId = useContainer(deep);
useRecordingStatus hook to get audio recording status every second (by default).
const audioRecordingStatus = useRecordingStatus({intervalInMs?});
useRecordingCycle hook to fire the recording cycle. Recording cycle records audiochunks of a given duration and uploads them as a links structure inside deep database.
const sounds = useRecordingCycle({ deep, recording, containerLinkId, duration: 5000 });
Feel free to contribute. Please fork the repository and submit a pull request for any bugs, improvements, or features.