1.2.7-dev.28 • Published 1 year ago

@deep-foundation/capacitor-voice-recorder v1.2.7-dev.28

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

npm Gitpod Discord

Provides links&functions based on capacitor-voice-recorder.

Documentation

List of links

AudioRecords

The AudioRecords link serves as a container for link structures representing records inside deep.

Sound

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.

Prerequisitions

  • Install this package in your deep by using npm-packager
  • Provide permissions to this package and its dependencies.

Usage

  1. Import the library into your TypeScript project:
import Recorder, { createContainer } from "@deep-foundation/capacitor-voice-recorder";
  1. Create container link of type "AudioRecords" to store Recorder data:
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.

  1. Getting permissions:

Call getAudioRecordingPermissions method of the Recorder to get audio recording and microphone usage permissions for your app.

const permissionSatus = await Recorder.getAudioRecordingPermissions(); 
  1. Recording Audio:

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
});
  1. Download records from deep database:

Download all existing records made by this recorder as array of IRecord records.

const records = Recorder.downloadRecords(deep); 

React Usage

  1. Import VoiceRecorder react component or hooks:
import { WithVoiceRecorder, VoiceRecorder, useContainer, useRecordingCycle, useRecordingStatus } from "@deep-foundation/capacitor-voice-recorder";
  1. Create VoiceRecorder component instance inside your deep app and pass a DeepClient instance.
  <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>
  1. Custom hooks can be used anywhere in your deep app:

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 }); 

Contribution

Feel free to contribute. Please fork the repository and submit a pull request for any bugs, improvements, or features.

1.2.7-dev.28

1 year ago

1.2.7-dev.27

1 year ago

1.2.7-dev.26

1 year ago

1.2.7-dev.25

1 year ago

1.2.7-dev.24

2 years ago

1.2.0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

1.2.7-dev.2

2 years ago

1.2.7-dev.3

2 years ago

1.2.7-dev.0

2 years ago

1.2.6

2 years ago

1.2.7-dev.1

2 years ago

1.2.5

2 years ago

1.2.7-dev.6

2 years ago

1.2.4

2 years ago

1.2.7-dev.7

2 years ago

1.2.3

2 years ago

1.2.7-dev.4

2 years ago

1.2.2

2 years ago

1.2.7-dev.5

2 years ago

1.2.1

2 years ago

1.2.7-dev.8

2 years ago

1.2.7-dev.9

2 years ago

0.1.3

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.2.7-dev.23

2 years ago

1.2.7-dev.22

2 years ago

1.2.7-dev.21

2 years ago

1.2.7-dev.20

2 years ago

1.2.7-dev.19

2 years ago

1.2.7-dev.18

2 years ago

1.2.7-dev.17

2 years ago

1.2.7-dev.16

2 years ago

1.2.7-dev.14

2 years ago

1.2.7-dev.13

2 years ago

1.2.7-dev.12

2 years ago

1.2.7-dev.11

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.0.10

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago