diff --git a/CHANGELOG.md b/CHANGELOG.md index 19488a3..57789dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog All changes to this project will be documented in this file. +## [0.2.4] - 2024-08-20 +- Add `timeslice` parameter + ## [0.2.3] - 2023-07-20 - add effects alpha version diff --git a/README.md b/README.md index 27aa346..f55d5b9 100644 --- a/README.md +++ b/README.md @@ -414,11 +414,13 @@ Using delegated upload tokens for authentication is best options when uploading ###### Common options -| Option name | Mandatory | Type | Description | -| ----------: | --------- | ------ | ------------------------------------------------------------------- | -| videoName | no | string | the name of your recorded video (overrides the default "file" name) | -| apiHost | no | string | api.video host (default: ws.api.video) | -| retries | no | number | number of retries when an API call fails (default: 5) | +| Option name | Mandatory | Type | Description | +| ----------: | ------------------ | ------ | ------------------------------------------------------------------- | +| videoName | no | string | the name of your recorded video (overrides the default "file" name) | +| apiHost | no | string | api.video host (default: ws.api.video) | +| retries | no | number | number of retries when an API call fails (default: 5) | +| timeslice | no (default: 5000) | number | The number of milliseconds to record into each Blob. | + **Example** diff --git a/package-lock.json b/package-lock.json index d611078..59369ec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@api.video/media-stream-composer", - "version": "0.2.3", + "version": "0.2.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@api.video/media-stream-composer", - "version": "0.2.3", + "version": "0.2.4", "license": "MIT", "dependencies": { "@api.video/media-recorder": "^1.0.10", diff --git a/package.json b/package.json index 01d47c2..7d5a945 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@api.video/media-stream-composer", - "version": "0.2.3", + "version": "0.2.4", "description": "api.video media stream composer", "repository": { "type": "git", diff --git a/src/index.ts b/src/index.ts index bea5891..7d017df 100644 --- a/src/index.ts +++ b/src/index.ts @@ -46,7 +46,9 @@ declare global { export type MouseTool = "draw" | "move-resize"; -type RecordingOptions = RecorderOptions & (ProgressiveUploaderOptionsWithUploadToken | ProgressiveUploaderOptionsWithAccessToken); +type RecordingOptions = RecorderOptions & (ProgressiveUploaderOptionsWithUploadToken | ProgressiveUploaderOptionsWithAccessToken) & {timeslice?: number}; + +const DEFAULT_TIMESLICE = 5000; export class MediaStreamComposer { private result: MediaStream | null = null; @@ -170,7 +172,9 @@ export class MediaStreamComposer { public startRecording(options: RecordingOptions) { if(!this.started) this.init(); - + + this._updateAudioDelay(Math.min(5000, options.timeslice || DEFAULT_TIMESLICE)); + this.recorder = new ApiVideoMediaRecorder(this.result!, { ...options, origin: { @@ -187,7 +191,7 @@ export class MediaStreamComposer { this.recorder?.addEventListener(event, (e) => this.eventTarget.dispatchEvent(Object.assign(new Event(event), { data: (e as any).data }))); }); - this.recorder.start(); + this.recorder.start({ timeslice: options.timeslice || DEFAULT_TIMESLICE }); } public destroy() {