@vidtreo/recorder-react 1.8.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -5
- package/dist/index.d.ts +22 -2
- package/dist/index.js +1 -1
- package/dist/recorder-react.css +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ npm install @vidtreo/recorder-react
|
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
**Peer Dependencies:**
|
|
12
|
-
- `@vidtreo/recorder >=1.0
|
|
12
|
+
- `@vidtreo/recorder >=1.9.0`
|
|
13
13
|
- `react >=18.0.0`
|
|
14
14
|
- `react-dom >=18.0.0`
|
|
15
15
|
|
|
@@ -48,6 +48,7 @@ import VidtreoRecorder from '@vidtreo/recorder-react';
|
|
|
48
48
|
|------|------|----------|---------|-------------|
|
|
49
49
|
| `apiKey` | `string` | No* | - | API key for authentication. Required if `VIDTREO_API_KEY` env var not set and `getAccessToken` is not used. |
|
|
50
50
|
| `getAccessToken` | `() => Promise<string>` | No* | - | Returns a short-lived desktop access token minted by your server. Use instead of `apiKey` (exactly one of the two; passing both shows a configuration error, see [Credentials](#temporary-access-tokens)). Called again whenever a fresh token is needed, including when a queued upload resumes after a reload. |
|
|
51
|
+
| `audioOnly` | `boolean` | No | `false` | Record audio from the microphone only. See [Audio-Only Recording](#audio-only-recording) |
|
|
51
52
|
| `countdownDuration` | `number` | No | - | Countdown duration in milliseconds before recording starts |
|
|
52
53
|
| `minTimeRecord` | `number` | No | - | Minimum recording time in milliseconds before stop is allowed. Must not be greater than `maxRecordingTime` when both are positive. |
|
|
53
54
|
| `maxRecordingTime` | `number` | No | - | Maximum recording time in milliseconds |
|
|
@@ -74,6 +75,29 @@ import VidtreoRecorder from '@vidtreo/recorder-react';
|
|
|
74
75
|
`tabVisibilityOverlayText` is optional. When `enableTabVisibilityOverlay` is enabled and text is omitted, the component
|
|
75
76
|
uses a localized default based on `lang` and `texts`. Overlay rendering is skipped for screen capture recordings.
|
|
76
77
|
|
|
78
|
+
### Audio-Only Recording
|
|
79
|
+
|
|
80
|
+
Set `audioOnly` to record from the microphone only. The camera is never requested and no video preview is rendered. The recorder shows a compact voice-note pill (about 20rem wide, 56px high): a red record/stop button, a live waveform of dots that freezes while paused or uploading, the elapsed time (with `/ 10:00` when the environment sets a maximum duration) and a microphone button that opens a menu with the microphone selector, plus pause/resume and mute while recording. Status text, permission requests, errors, upload progress (`Uploading 42%`) and the completion message appear in a small caption below the pill.
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
<VidtreoRecorder
|
|
84
|
+
apiKey="your-api-key"
|
|
85
|
+
audioOnly
|
|
86
|
+
onUploadComplete={(result) => {
|
|
87
|
+
if (result.mediaType === 'audio') {
|
|
88
|
+
console.log('Audio uploaded:', result.audioId);
|
|
89
|
+
}
|
|
90
|
+
}}
|
|
91
|
+
/>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
- Audio recording must be enabled for the environment in the backend. When it is not, the recorder shows "Audio recording is not enabled for this environment" (`audioRecordingDisabled`) and `onError` receives an error whose `code` is `"recording.audio-disabled"` (`ERROR_AUDIO_RECORDING_DISABLED` from `@vidtreo/recorder`).
|
|
95
|
+
- The microphone selector, mute, pause/resume and stop work as for video, from the pill and its menu. The camera selector, source switching and the tab visibility overlay are not shown.
|
|
96
|
+
- The permission flow asks only for the microphone.
|
|
97
|
+
- On mobile, `overlay` and `embed` show the same pill. `mobileMode="native"` and `nativeCamera` are ignored and fall back to `overlay`, because the native camera only captures video.
|
|
98
|
+
- Format, bitrate, channels, processing and the maximum duration come from the environment audio settings. The recorder stops automatically at the maximum duration.
|
|
99
|
+
- Demo mode has no environment audio settings, so audio-only recording needs a real backend.
|
|
100
|
+
|
|
77
101
|
### Example with Callbacks
|
|
78
102
|
|
|
79
103
|
```tsx
|
|
@@ -143,6 +167,8 @@ type RecordingUploadResult = {
|
|
|
143
167
|
transferredAt: string | null;
|
|
144
168
|
r2DeleteAfter: string | null;
|
|
145
169
|
r2DeletedAt: string | null;
|
|
170
|
+
mediaType?: 'audio' | 'video'; // 'audio' for audio-only recordings
|
|
171
|
+
audioId?: string; // the audio id, set for audio-only recordings
|
|
146
172
|
};
|
|
147
173
|
```
|
|
148
174
|
|
|
@@ -168,7 +194,7 @@ import VidtreoRecorder, {
|
|
|
168
194
|
|
|
169
195
|
| Code | Meaning |
|
|
170
196
|
|------|---------|
|
|
171
|
-
| `upload.insufficient-credits` | The account has no credits left (HTTP 402). The upload is
|
|
197
|
+
| `upload.insufficient-credits` | The account has no credits left (HTTP 402). The upload stays queued and is retried every 5 minutes; `onUploadError` fires on each rejected attempt. The first rejection of each queued upload per page session also sets the built-in dialog and `uploadErrorCode`; repeated rejections only call `onUploadError` (no `onError`, no state change). |
|
|
172
198
|
|
|
173
199
|
`getUploadErrorCode` returns `null` for other errors. Network errors are retried automatically before they are reported.
|
|
174
200
|
|
|
@@ -247,8 +273,8 @@ function CustomRecorder() {
|
|
|
247
273
|
|
|
248
274
|
### Hook Actions
|
|
249
275
|
|
|
250
|
-
- `startRecording(sourceType?: 'camera' | 'screen')` - Start recording
|
|
251
|
-
- `stopRecording()` - Stop recording and upload
|
|
276
|
+
- `startRecording(sourceType?: 'camera' | 'screen' | 'audio')` - Start recording
|
|
277
|
+
- `stopRecording()` - Stop recording and upload. Resolves with `{ recordingId, uploadUrl, blob, mediaType }`
|
|
252
278
|
- `pauseRecording()` - Pause recording
|
|
253
279
|
- `resumeRecording()` - Resume recording
|
|
254
280
|
- `toggleMute()` - Toggle mute state
|
|
@@ -256,7 +282,7 @@ function CustomRecorder() {
|
|
|
256
282
|
- `reselectScreenSource()` - Pick another screen or window without changing the source type (resolves `false` when cancelled)
|
|
257
283
|
- `changeCamera(deviceId: string)` - Change camera device
|
|
258
284
|
- `changeMic(deviceId: string)` - Change microphone device
|
|
259
|
-
- `startPreview(sourceType?: 'camera' | 'screen')` - Start preview stream
|
|
285
|
+
- `startPreview(sourceType?: 'camera' | 'screen' | 'audio')` - Start preview stream
|
|
260
286
|
- `downloadVideo()` - Download the recorded video (demo mode)
|
|
261
287
|
- `clearUploadError()` - Clear `uploadErrorCode` after the user dismisses the upload error
|
|
262
288
|
- `cleanup()` - Clean up resources
|
|
@@ -585,6 +611,23 @@ function App() {
|
|
|
585
611
|
| `permissionFlowRecoveryTitle` | Allow access to continue | Permite el acceso para continuar |
|
|
586
612
|
| `permissionFlowRecoveryInstructions` | Open your browser settings and allow camera and microphone access, then try again. | Abre la configuración de tu navegador y permite el acceso a la cámara y micrófono, luego intenta de nuevo. |
|
|
587
613
|
| `permissionFlowConnecting` | Setting up... | Preparando... |
|
|
614
|
+
| `initializingMicrophone` | Initializing microphone... | Iniciando micrófono... |
|
|
615
|
+
| `grantMicrophonePermission` | Grant microphone permission when prompted | Concede el permiso de micrófono cuando se te solicite |
|
|
616
|
+
| `retryMicrophone` | Retry Microphone | Reintentar micrófono |
|
|
617
|
+
| `audioOnlyReady` | Ready to record | Listo para grabar |
|
|
618
|
+
| `audioOnlyRecording` | Recording | Grabando |
|
|
619
|
+
| `audioOnlyPaused` | Paused | En pausa |
|
|
620
|
+
| `audioOnlyUploading` | Uploading {progress}% | Subiendo {progress}% |
|
|
621
|
+
| `audioOnlyUploaded` | Upload complete | Subida completada |
|
|
622
|
+
| `audioOnlyElapsedTime` | Elapsed time | Tiempo transcurrido |
|
|
623
|
+
| `audioOnlyNoMicrophones` | No microphones available | No hay micrófonos disponibles |
|
|
624
|
+
| `audioRecordingDisabledTitle` | Audio recording unavailable | Grabación de audio no disponible |
|
|
625
|
+
| `audioRecordingDisabled` | Audio recording is not enabled for this environment | La grabación de audio no está habilitada para este entorno |
|
|
626
|
+
| `permissionFlowMicrophoneOnlyTitle` | Microphone | Micrófono |
|
|
627
|
+
| `permissionFlowMicrophoneOnlyLabel` | We need access to your microphone to start recording | Necesitamos acceso a tu micrófono para comenzar a grabar |
|
|
628
|
+
| `permissionFlowMicrophoneOnlyRecoveryInstructions` | Open your browser settings and allow microphone access, then try again. | Abre la configuración de tu navegador y permite el acceso al micrófono, luego intenta de nuevo. |
|
|
629
|
+
| `mobileOpenMicrophoneTitle` | Microphone | Micrófono |
|
|
630
|
+
| `mobileOpenMicrophoneDescription` | We need access to your microphone to start recording | Necesitamos acceso a tu micrófono para comenzar a grabar |
|
|
588
631
|
|
|
589
632
|
`TranslationKeys` lists every available key.
|
|
590
633
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccessTokenProvider, AccessTokenProvider as AccessTokenProvider$1, AudioWarning, AudioWarning as AudioWarning$1, CONFIG_ERROR_CREDENTIAL_CONFLICT, ERROR_PICTURE_IN_PICTURE_UNSUPPORTED, ERROR_SCREEN_SELECTION_CANCELLED, LocalRecording, LocalRecording as LocalRecording$1, PictureInPictureConfig, PictureInPictureConfig as PictureInPictureConfig$1, PictureInPictureConfigInput, PictureInPictureConfigInput as PictureInPictureConfigInput$1, PictureInPicturePlacement, PictureInPicturePoint, PictureInPicturePosition, PictureInPictureShape, RecorderController, RecordingState, RecordingState as RecordingState$1, RecordingUploadResult, RecordingUploadResult as RecordingUploadResult$1, SourceType, SourceType as SourceType$1, UPLOAD_ERROR_INSUFFICIENT_CREDITS, UploadErrorCode, UploadErrorCode as UploadErrorCode$1, UploadProgressPhase, UploadProgressPhase as UploadProgressPhase$1, getUploadErrorCode, isCredentialConflictError, isPictureInPictureSupported } from "@vidtreo/recorder";
|
|
1
|
+
import { AccessTokenProvider, AccessTokenProvider as AccessTokenProvider$1, AudioWarning, AudioWarning as AudioWarning$1, CONFIG_ERROR_CREDENTIAL_CONFLICT, ERROR_PICTURE_IN_PICTURE_UNSUPPORTED, ERROR_SCREEN_SELECTION_CANCELLED, LocalRecording, LocalRecording as LocalRecording$1, MediaType, MediaType as MediaType$1, PictureInPictureConfig, PictureInPictureConfig as PictureInPictureConfig$1, PictureInPictureConfigInput, PictureInPictureConfigInput as PictureInPictureConfigInput$1, PictureInPicturePlacement, PictureInPicturePoint, PictureInPicturePosition, PictureInPictureShape, RecorderController, RecordingState, RecordingState as RecordingState$1, RecordingUploadResult, RecordingUploadResult as RecordingUploadResult$1, SourceType, SourceType as SourceType$1, UPLOAD_ERROR_INSUFFICIENT_CREDITS, UploadErrorCode, UploadErrorCode as UploadErrorCode$1, UploadProgressPhase, UploadProgressPhase as UploadProgressPhase$1, getUploadErrorCode, isCredentialConflictError, isPictureInPictureSupported } from "@vidtreo/recorder";
|
|
2
2
|
import React from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/i18n/translations.d.ts
|
|
@@ -126,6 +126,23 @@ type TranslationKeys = {
|
|
|
126
126
|
permissionFlowRecoveryTitle: string;
|
|
127
127
|
permissionFlowRecoveryInstructions: string;
|
|
128
128
|
permissionFlowConnecting: string;
|
|
129
|
+
initializingMicrophone: string;
|
|
130
|
+
grantMicrophonePermission: string;
|
|
131
|
+
retryMicrophone: string;
|
|
132
|
+
audioOnlyReady: string;
|
|
133
|
+
audioOnlyRecording: string;
|
|
134
|
+
audioOnlyPaused: string;
|
|
135
|
+
audioOnlyUploading: string;
|
|
136
|
+
audioOnlyUploaded: string;
|
|
137
|
+
audioOnlyElapsedTime: string;
|
|
138
|
+
audioOnlyNoMicrophones: string;
|
|
139
|
+
audioRecordingDisabledTitle: string;
|
|
140
|
+
audioRecordingDisabled: string;
|
|
141
|
+
permissionFlowMicrophoneOnlyTitle: string;
|
|
142
|
+
permissionFlowMicrophoneOnlyLabel: string;
|
|
143
|
+
permissionFlowMicrophoneOnlyRecoveryInstructions: string;
|
|
144
|
+
mobileOpenMicrophoneTitle: string;
|
|
145
|
+
mobileOpenMicrophoneDescription: string;
|
|
129
146
|
};
|
|
130
147
|
type PartialTranslations = Partial<TranslationKeys>;
|
|
131
148
|
//#endregion
|
|
@@ -152,6 +169,7 @@ type RecordingPrompt = {
|
|
|
152
169
|
};
|
|
153
170
|
type BaseRecorderProps = {
|
|
154
171
|
backendUrl?: string;
|
|
172
|
+
audioOnly?: boolean;
|
|
155
173
|
countdownDuration?: number;
|
|
156
174
|
minTimeRecord?: number;
|
|
157
175
|
maxRecordingTime?: number;
|
|
@@ -196,6 +214,7 @@ type UseVidtreoRecorderConfig = {
|
|
|
196
214
|
apiKey?: string;
|
|
197
215
|
getAccessToken?: AccessTokenProvider$1;
|
|
198
216
|
backendUrl?: string;
|
|
217
|
+
audioOnly?: boolean;
|
|
199
218
|
countdownDuration?: number;
|
|
200
219
|
minTimeRecord?: number;
|
|
201
220
|
maxRecordingTime?: number;
|
|
@@ -284,6 +303,7 @@ type RecordingStopResult = {
|
|
|
284
303
|
recordingId: string;
|
|
285
304
|
uploadUrl: string;
|
|
286
305
|
blob: Blob;
|
|
306
|
+
mediaType: MediaType$1;
|
|
287
307
|
};
|
|
288
308
|
type UseVidtreoRecorderReturn = {
|
|
289
309
|
state: VidtreoRecorderState;
|
|
@@ -298,4 +318,4 @@ declare function VidtreoRecorder(props: VidtreoRecorderProps): React.JSX.Element
|
|
|
298
318
|
//#region src/hooks/use-vidtreo-recorder.d.ts
|
|
299
319
|
declare function useVidtreoRecorder(config: UseVidtreoRecorderConfig): UseVidtreoRecorderReturn;
|
|
300
320
|
//#endregion
|
|
301
|
-
export { type AccessTokenProvider, type AudioWarning, CONFIG_ERROR_CREDENTIAL_CONFLICT, ERROR_PICTURE_IN_PICTURE_UNSUPPORTED, ERROR_SCREEN_SELECTION_CANCELLED, type LocalRecording, MobileMode, type PartialTranslations, type PictureInPictureConfig, type PictureInPictureConfigInput, type PictureInPicturePlacement, type PictureInPicturePoint, type PictureInPicturePosition, type PictureInPictureShape, RecordingPrompt, RecordingPromptCountdown, RecordingPromptCountdownPlacement, type RecordingState, RecordingStopResult, type RecordingUploadResult, type SourceType, type TranslationKeys, UPLOAD_ERROR_INSUFFICIENT_CREDITS, type UploadErrorCode, type UploadProgressPhase, UseVidtreoRecorderConfig, UseVidtreoRecorderReturn, VidtreoRecorder, VidtreoRecorder as VidtreoRecorderSSR, VidtreoRecorderActions, VidtreoRecorderProps, VidtreoRecorderState, getUploadErrorCode, isCredentialConflictError, isPictureInPictureSupported, useVidtreoRecorder };
|
|
321
|
+
export { type AccessTokenProvider, type AudioWarning, CONFIG_ERROR_CREDENTIAL_CONFLICT, ERROR_PICTURE_IN_PICTURE_UNSUPPORTED, ERROR_SCREEN_SELECTION_CANCELLED, type LocalRecording, type MediaType, MobileMode, type PartialTranslations, type PictureInPictureConfig, type PictureInPictureConfigInput, type PictureInPicturePlacement, type PictureInPicturePoint, type PictureInPicturePosition, type PictureInPictureShape, RecordingPrompt, RecordingPromptCountdown, RecordingPromptCountdownPlacement, type RecordingState, RecordingStopResult, type RecordingUploadResult, type SourceType, type TranslationKeys, UPLOAD_ERROR_INSUFFICIENT_CREDITS, type UploadErrorCode, type UploadProgressPhase, UseVidtreoRecorderConfig, UseVidtreoRecorderReturn, VidtreoRecorder, VidtreoRecorder as VidtreoRecorderSSR, VidtreoRecorderActions, VidtreoRecorderProps, VidtreoRecorderState, getUploadErrorCode, isCredentialConflictError, isPictureInPictureSupported, useVidtreoRecorder };
|