capacitor-plugin-recorder
v0.0.1
Published
ee
Downloads
4
Readme
capacitor-plugin-recorder
ee
Install
npm install capacitor-plugin-recorder
npx cap syncAPI
requestPermission()checkPermission()startRecord(...)stopRecord()pauseRecord()resumeRecord()preparePlay(...)play(...)pausePlay(...)resumePlay(...)stopPlay(...)seekTo(...)getPlaybackStatus(...)getRecordingStatus()destroyPlayer(...)addListener('recordingStatusChange', ...)addListener('playbackStatusChange', ...)removeAllListeners()- Interfaces
- Type Aliases
requestPermission()
requestPermission() => Promise<PermissionStatus>Request microphone permission
Returns: Promise<PermissionStatus>
checkPermission()
checkPermission() => Promise<PermissionStatus>Check current permission status
Returns: Promise<PermissionStatus>
startRecord(...)
startRecord(options?: StartRecordOptions | undefined) => Promise<void>Start recording audio
| Param | Type |
| ------------- | ----------------------------------------------------------------- |
| options | StartRecordOptions |
stopRecord()
stopRecord() => Promise<StopRecordResult>Stop recording and return the recorded file path
Returns: Promise<StopRecordResult>
pauseRecord()
pauseRecord() => Promise<void>Pause the current recording
resumeRecord()
resumeRecord() => Promise<void>Resume a paused recording
preparePlay(...)
preparePlay(options: PlayOptions) => Promise<PreparePlayResult>Prepare an audio file for playback (loads metadata without playing). Returns a playerId that must be used for all subsequent operations on this player.
| Param | Type |
| ------------- | --------------------------------------------------- |
| options | PlayOptions |
Returns: Promise<PreparePlayResult>
play(...)
play(options: PlayerOptions) => Promise<void>Start playing an audio file
| Param | Type |
| ------------- | ------------------------------------------------------- |
| options | PlayerOptions |
pausePlay(...)
pausePlay(options: PlayerOptions) => Promise<void>Pause audio playback
| Param | Type |
| ------------- | ------------------------------------------------------- |
| options | PlayerOptions |
resumePlay(...)
resumePlay(options: PlayerOptions) => Promise<void>Resume paused audio playback
| Param | Type |
| ------------- | ------------------------------------------------------- |
| options | PlayerOptions |
stopPlay(...)
stopPlay(options: PlayerOptions) => Promise<void>Stop audio playback
| Param | Type |
| ------------- | ------------------------------------------------------- |
| options | PlayerOptions |
seekTo(...)
seekTo(options: SeekOptions) => Promise<void>Seek to a specific position in the audio
| Param | Type |
| ------------- | --------------------------------------------------- |
| options | SeekOptions |
getPlaybackStatus(...)
getPlaybackStatus(options: PlayerOptions) => Promise<PlaybackStatusChangeEvent>Get current playback status for a specific player
| Param | Type |
| ------------- | ------------------------------------------------------- |
| options | PlayerOptions |
Returns: Promise<PlaybackStatusChangeEvent>
getRecordingStatus()
getRecordingStatus() => Promise<RecordingStatusChangeEvent>Get current recording status
Returns: Promise<RecordingStatusChangeEvent>
destroyPlayer(...)
destroyPlayer(options: PlayerOptions) => Promise<void>Destroy a player and release its resources
| Param | Type |
| ------------- | ------------------------------------------------------- |
| options | PlayerOptions |
addListener('recordingStatusChange', ...)
addListener(eventName: 'recordingStatusChange', listenerFunc: (event: RecordingStatusChangeEvent) => void) => Promise<PluginListenerHandle>Listen for recording status changes
| Param | Type |
| ------------------ | ----------------------------------------------------------------------------------------------------- |
| eventName | 'recordingStatusChange' |
| listenerFunc | (event: RecordingStatusChangeEvent) => void |
Returns: Promise<PluginListenerHandle>
addListener('playbackStatusChange', ...)
addListener(eventName: 'playbackStatusChange', listenerFunc: (event: PlaybackStatusChangeEvent) => void) => Promise<PluginListenerHandle>Listen for playback status changes (includes playerId to identify which player)
| Param | Type |
| ------------------ | --------------------------------------------------------------------------------------------------- |
| eventName | 'playbackStatusChange' |
| listenerFunc | (event: PlaybackStatusChangeEvent) => void |
Returns: Promise<PluginListenerHandle>
removeAllListeners()
removeAllListeners() => Promise<void>Remove all listeners
Interfaces
PermissionStatus
| Prop | Type |
| ---------------- | ---------------------------------------------- |
| microphone | 'granted' | 'denied' | 'prompt' |
StartRecordOptions
| Prop | Type | Description |
| ---------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| path | string | Optional relative path for the recording (including extension), relative to the app's data directory. If not provided, a default filename will be used. |
StopRecordResult
| Prop | Type | Description |
| -------------- | ------------------- | ----------------------------------------- |
| path | string | Path to the recorded file |
| duration | number | Duration of the recording in milliseconds |
PreparePlayResult
| Prop | Type | Description |
| -------------- | ------------------- | ------------------------------------------ |
| playerId | string | Unique identifier for this player instance |
| duration | number | Duration of the audio in milliseconds |
PlayOptions
| Prop | Type | Description |
| ---------- | ------------------- | ------------------------------------------------------------------------------ |
| path | string | Relative path to the audio file to play (relative to the app's data directory) |
PlayerOptions
| Prop | Type | Description |
| -------------- | ------------------- | --------------------------------------- |
| playerId | string | The player ID returned from preparePlay |
SeekOptions
| Prop | Type | Description |
| -------------- | ------------------- | --------------------------------------- |
| playerId | string | The player ID returned from preparePlay |
| position | number | Position to seek to in milliseconds |
PlaybackStatusChangeEvent
| Prop | Type | Description |
| --------------------- | --------------------------------------------------------- | ------------------------------------------- |
| playerId | string | The player ID this event belongs to |
| status | PlaybackStatus | |
| currentPosition | number | Current playback position in milliseconds |
| duration | number | Total duration of the audio in milliseconds |
RecordingStatusChangeEvent
| Prop | Type | Description |
| -------------- | ----------------------------------------------------------- | ------------------------------------------ |
| status | RecordingStatus | |
| duration | number | Current recording duration in milliseconds |
PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove | () => Promise<void> |
Type Aliases
PlaybackStatus
'playing' | 'paused' | 'stopped' | 'ended'
RecordingStatus
'recording' | 'paused' | 'stopped'
