Vidtreo

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

OptionTypeRequiredDefaultDescription
apiKeystringYes-Your VIDTREO API key
apiUrlstringNohttps://core.vidtreo.comAPI endpoint
enableSourceSwitchingbooleanNotrueAllow camera/screen switching
enableMutebooleanNotrueEnable mute functionality
enablePausebooleanNotrueEnable pause/resume
enableDeviceChangebooleanNotrueEnable device selection
maxRecordingTimenumberNoundefinedMax duration (ms)
countdownDurationnumberNo3000Pre-recording countdown (ms)
userMetadataobjectNoundefinedCustom metadata
enableTabVisibilityOverlaybooleanNofalseShow tab hidden overlay
tabVisibilityOverlayTextstringNo-Custom overlay text
onUploadCompletefunctionNo-Upload success callback
onUploadProgressfunctionNo-Upload progress callback
onUploadErrorfunctionNo-Upload error callback
onRecordingStartfunctionNo-Recording start callback
onRecordingStopfunctionNo-Recording stop callback
onErrorfunctionNo-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(): void

pauseRecording() / resumeRecording()

Control recording pause state.

recorder.pauseRecording(): void
recorder.resumeRecording(): void

getRecordingState()

Get current recording state.

recorder.getRecordingState(): RecordingState
// Returns: 'idle' | 'countdown' | 'recording'

getStream()

Get current media stream.

recorder.getStream(): MediaStream | null

getAvailableDevices()

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(): boolean

cleanup()

Release all resources.

recorder.cleanup(): void

Example

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

On this page