VidtreoRecorder API
Complete API reference for the VidtreoRecorder class.
VidtreoRecorder API
The VidtreoRecorder class is the core of the VIDTREO SDK. It handles all recording, transcoding, and upload functionality.
Constructor
new VidtreoRecorder(config: VidtreoRecorderConfig)Config Options
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
apiKey | string | Yes | - | Your VIDTREO API key |
apiUrl | string | No | https://core.vidtreo.com | API endpoint |
enableSourceSwitching | boolean | No | true | Allow camera/screen switching |
enableMute | boolean | No | true | Enable mute functionality |
enablePause | boolean | No | true | Enable pause/resume |
enableDeviceChange | boolean | No | true | Enable device selection |
maxRecordingTime | number | No | undefined | Max duration (ms) |
countdownDuration | number | No | 3000 | Pre-recording countdown (ms) |
userMetadata | object | No | undefined | Custom metadata |
enableTabVisibilityOverlay | boolean | No | false | Show tab hidden overlay |
tabVisibilityOverlayText | string | No | - | Custom overlay text |
onUploadComplete | function | No | - | Upload success callback |
onUploadProgress | function | No | - | Upload progress callback |
onUploadError | function | No | - | Upload error callback |
onRecordingStart | function | No | - | Recording start callback |
onRecordingStop | function | No | - | Recording stop callback |
onError | function | No | - | Error callback |
Methods
initialize()
Initialize the recorder. Must be called before other methods.
await recorder.initialize(): Promise<void>startPreview()
Start camera or screen preview without recording.
await recorder.startPreview(sourceType?: SourceType): Promise<MediaStream>Parameters:
sourceType:'camera'|'screen'(default:'camera')
Returns: MediaStream — The preview stream
startRecording()
Start recording from camera or screen.
await recorder.startRecording(
options?: RecordingStartOptions,
sourceType?: SourceType
): Promise<void>Parameters:
options: Recording constraints (optional)sourceType:'camera'|'screen'(default:'camera')
stopRecording()
Stop recording and trigger upload.
await recorder.stopRecording(): Promise<RecordingStopResult>Returns:
interface RecordingStopResult {
recordingId: string;
uploadUrl: string;
blob: Blob;
}switchSource()
Switch between camera and screen during recording.
await recorder.switchSource(sourceType: SourceType): Promise<void>muteAudio() / unmuteAudio() / toggleMute()
Control audio muting.
recorder.muteAudio(): void
recorder.unmuteAudio(): void
recorder.toggleMute(): voidpauseRecording() / resumeRecording()
Control recording pause state.
recorder.pauseRecording(): void
recorder.resumeRecording(): voidgetRecordingState()
Get current recording state.
recorder.getRecordingState(): RecordingState
// Returns: 'idle' | 'countdown' | 'recording'getStream()
Get current media stream.
recorder.getStream(): MediaStream | nullgetAvailableDevices()
Get available cameras and microphones.
await recorder.getAvailableDevices(): Promise<AvailableDevices>Returns:
interface AvailableDevices {
video: MediaDeviceInfo[];
audio: MediaDeviceInfo[];
}isMuted() / isPaused()
Check mute and pause state.
recorder.isMuted(): boolean
recorder.isPaused(): booleancleanup()
Release all resources.
recorder.cleanup(): voidExample
import { VidtreoRecorder } from '@vidtreo/recorder';
const recorder = new VidtreoRecorder({
apiKey: 'your-api-key',
maxRecordingTime: 300000,
onUploadComplete: (result) => {
console.log('Video URL:', result.uploadUrl);
},
onError: (error) => {
console.error('Error:', error);
}
});
// Initialize
await recorder.initialize();
// Start preview
const stream = await recorder.startPreview('camera');
document.querySelector('video').srcObject = stream;
// Start recording
await recorder.startRecording();
// Stop and upload
const result = await recorder.stopRecording();
// Cleanup
recorder.cleanup();See Also
- Hooks API — React hooks reference
- Types Reference — TypeScript types
- Vanilla JS Guide — Integration guide