@vidtreo/recorder 0.9.8 → 1.0.0-rc1

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 CHANGED
@@ -15,7 +15,7 @@ import { VidtreoRecorder } from '@vidtreo/recorder';
15
15
 
16
16
  const recorder = new VidtreoRecorder({
17
17
  apiKey: 'your-api-key',
18
- apiUrl: 'https://api.vidtreo.com', // Optional, defaults to https://api.vidtreo.com
18
+ apiUrl: 'https://core.vidtreo.com', // Optional, defaults to https://core.vidtreo.com
19
19
  enableSourceSwitching: true,
20
20
  maxRecordingTime: 300000,
21
21
  onUploadComplete: (result) => {
@@ -47,7 +47,7 @@ Creates a new recorder instance with the specified configuration.
47
47
  **Parameters:**
48
48
 
49
49
  - `config.apiKey` (required): Your API key for backend authentication
50
- - `config.apiUrl` (optional): Your backend API URL endpoint. Defaults to `https://api.vidtreo.com` if not provided
50
+ - `config.apiUrl` (optional): Your backend API URL endpoint. Defaults to `https://core.vidtreo.com` if not provided
51
51
  - `config.enableSourceSwitching` (optional): Enable switching between camera and screen during recording. Default: `false`
52
52
  - `config.enableMute` (optional): Enable mute/unmute functionality. When disabled, `muteAudio()`, `unmuteAudio()`, and `toggleMute()` will throw errors. Default: `true`
53
53
  - `config.enablePause` (optional): Enable pause/resume functionality. When disabled, `pauseRecording()` and `resumeRecording()` will throw errors. Default: `true`
@@ -281,7 +281,7 @@ import { VidtreoRecorder } from '@vidtreo/recorder';
281
281
 
282
282
  const recorder = new VidtreoRecorder({
283
283
  apiKey: 'your-api-key',
284
- apiUrl: 'https://api.example.com', // Optional, defaults to https://api.vidtreo.com
284
+ apiUrl: 'https://api.example.com', // Optional, defaults to https://core.vidtreo.com
285
285
  onUploadComplete: (result) => {
286
286
  console.log('Uploaded:', result.uploadUrl);
287
287
  },
@@ -612,7 +612,6 @@ const controller = new RecorderController({
612
612
 
613
613
  await controller.initialize({
614
614
  apiKey: 'your-api-key',
615
- backendUrl: 'https://api.example.com', // Optional, defaults to https://api.vidtreo.com
616
615
  });
617
616
  ```
618
617
 
package/dist/index.d.ts CHANGED
@@ -1025,7 +1025,7 @@ export declare const RESOLUTION_MAP: Record<BackendPreset, {
1025
1025
  width: number;
1026
1026
  height: number;
1027
1027
  }>;
1028
- export declare const DEFAULT_BACKEND_URL = "https://api.vidtreo.com";
1028
+ export declare const DEFAULT_BACKEND_URL = "https://core.vidtreo.com";
1029
1029
  export declare const DEFAULT_TRANSCODE_CONFIG: Readonly<TranscodeConfig>;
1030
1030
  export declare function getDefaultConfigForFormat(format: TranscodeConfig["format"]): TranscodeConfig;
1031
1031
 
@@ -1183,6 +1183,8 @@ export declare class RecordingManager {
1183
1183
  private isPaused;
1184
1184
  private maxRecordingTime;
1185
1185
  private maxTimeTimer;
1186
+ private recordingStartTime;
1187
+ private maxTimeRemaining;
1186
1188
  private recordingSeconds;
1187
1189
  private recordingIntervalId;
1188
1190
  private pauseStartTime;
@@ -1216,6 +1218,7 @@ export declare class RecordingManager {
1216
1218
  private resetPauseState;
1217
1219
  private updatePausedDuration;
1218
1220
  private startRecordingTimer;
1221
+ private startMaxTimeTimer;
1219
1222
  private clearTimer;
1220
1223
  private handleError;
1221
1224
  }
package/dist/index.js CHANGED
@@ -189,7 +189,7 @@ var RESOLUTION_MAP = {
189
189
  fhd: { width: 1920, height: 1080 },
190
190
  "4k": { width: 3840, height: 2160 }
191
191
  };
192
- var DEFAULT_BACKEND_URL = "https://api.vidtreo.com";
192
+ var DEFAULT_BACKEND_URL = "https://core.vidtreo.com";
193
193
  var DEFAULT_TRANSCODE_CONFIG = Object.freeze({
194
194
  format: "mp4",
195
195
  fps: 30,
@@ -12016,6 +12016,8 @@ class RecordingManager {
12016
12016
  isPaused = false;
12017
12017
  maxRecordingTime = null;
12018
12018
  maxTimeTimer = null;
12019
+ recordingStartTime = null;
12020
+ maxTimeRemaining = null;
12019
12021
  recordingSeconds = 0;
12020
12022
  recordingIntervalId = null;
12021
12023
  pauseStartTime = null;
@@ -12147,12 +12149,10 @@ class RecordingManager {
12147
12149
  return;
12148
12150
  }
12149
12151
  this.startRecordingTimer();
12152
+ this.recordingStartTime = Date.now();
12150
12153
  if (this.maxRecordingTime && this.maxRecordingTime > 0) {
12151
- this.maxTimeTimer = window.setTimeout(async () => {
12152
- if (this.recordingState === RECORDING_STATE_RECORDING) {
12153
- await this.stopRecording();
12154
- }
12155
- }, this.maxRecordingTime);
12154
+ this.maxTimeRemaining = this.maxRecordingTime;
12155
+ this.startMaxTimeTimer();
12156
12156
  }
12157
12157
  }
12158
12158
  async stopRecording() {
@@ -12191,6 +12191,12 @@ class RecordingManager {
12191
12191
  this.clearTimer(this.recordingIntervalId, clearInterval);
12192
12192
  this.recordingIntervalId = null;
12193
12193
  this.pauseStartTime = Date.now();
12194
+ if (this.maxTimeTimer !== null && this.recordingStartTime !== null && this.maxRecordingTime !== null) {
12195
+ const elapsed = Date.now() - this.recordingStartTime - this.totalPausedTime;
12196
+ this.maxTimeRemaining = Math.max(0, this.maxRecordingTime - elapsed);
12197
+ this.clearTimer(this.maxTimeTimer, clearTimeout);
12198
+ this.maxTimeTimer = null;
12199
+ }
12194
12200
  }
12195
12201
  resumeRecording() {
12196
12202
  if (this.recordingState !== RECORDING_STATE_RECORDING || !this.isPaused) {
@@ -12200,6 +12206,9 @@ class RecordingManager {
12200
12206
  this.isPaused = false;
12201
12207
  this.updatePausedDuration();
12202
12208
  this.startRecordingTimer();
12209
+ if (this.maxTimeRemaining !== null && this.maxTimeRemaining > 0) {
12210
+ this.startMaxTimeTimer();
12211
+ }
12203
12212
  }
12204
12213
  cancelCountdown() {
12205
12214
  this.clearTimer(this.countdownTimeoutId, clearTimeout);
@@ -12223,6 +12232,8 @@ class RecordingManager {
12223
12232
  this.recordingSeconds = 0;
12224
12233
  this.totalPausedTime = 0;
12225
12234
  this.pauseStartTime = null;
12235
+ this.recordingStartTime = null;
12236
+ this.maxTimeRemaining = null;
12226
12237
  }
12227
12238
  resetPauseState() {
12228
12239
  this.isPaused = false;
@@ -12246,6 +12257,17 @@ class RecordingManager {
12246
12257
  this.callbacks.onTimerUpdate(formatTime(this.recordingSeconds));
12247
12258
  }, RECORDING_TIMER_INTERVAL);
12248
12259
  }
12260
+ startMaxTimeTimer() {
12261
+ if (this.maxTimeRemaining === null || this.maxTimeRemaining <= 0) {
12262
+ return;
12263
+ }
12264
+ this.clearTimer(this.maxTimeTimer, clearTimeout);
12265
+ this.maxTimeTimer = window.setTimeout(async () => {
12266
+ if (this.recordingState === RECORDING_STATE_RECORDING && !this.isPaused) {
12267
+ await this.stopRecording();
12268
+ }
12269
+ }, this.maxTimeRemaining);
12270
+ }
12249
12271
  clearTimer(timerId, clearFn) {
12250
12272
  if (timerId !== null) {
12251
12273
  clearFn(timerId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vidtreo/recorder",
3
- "version": "0.9.8",
3
+ "version": "1.0.0-rc1",
4
4
  "type": "module",
5
5
  "description": "Vidtreo SDK for browser-based video recording and transcoding. Features include camera/screen recording, real-time MP4 transcoding, audio level analysis, mute/pause controls, source switching, device selection, and automatic backend uploads. Similar to Ziggeo and Addpipe, Vidtreo provides enterprise-grade video processing capabilities for web applications.",
6
6
  "main": "./dist/index.js",