Skip to content

Commit d70ab66

Browse files
committed
Add timeslice parameter
1 parent 26698b9 commit d70ab66

File tree

5 files changed

+20
-11
lines changed

5 files changed

+20
-11
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Changelog
22
All changes to this project will be documented in this file.
33

4+
## [0.2.4] - 2024-08-20
5+
- Add `timeslice` parameter
6+
47
## [0.2.3] - 2023-07-20
58
- add effects alpha version
69

README.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -414,11 +414,13 @@ Using delegated upload tokens for authentication is best options when uploading
414414
415415
###### Common options
416416
417-
| Option name | Mandatory | Type | Description |
418-
| ----------: | --------- | ------ | ------------------------------------------------------------------- |
419-
| videoName | no | string | the name of your recorded video (overrides the default "file" name) |
420-
| apiHost | no | string | api.video host (default: ws.api.video) |
421-
| retries | no | number | number of retries when an API call fails (default: 5) |
417+
| Option name | Mandatory | Type | Description |
418+
| ----------: | ------------------ | ------ | ------------------------------------------------------------------- |
419+
| videoName | no | string | the name of your recorded video (overrides the default "file" name) |
420+
| apiHost | no | string | api.video host (default: ws.api.video) |
421+
| retries | no | number | number of retries when an API call fails (default: 5) |
422+
| timeslice | no (default: 5000) | number | The number of milliseconds to record into each Blob. |
423+
422424
423425
424426
**Example**

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@api.video/media-stream-composer",
3-
"version": "0.2.3",
3+
"version": "0.2.4",
44
"description": "api.video media stream composer",
55
"repository": {
66
"type": "git",

src/index.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ declare global {
4646

4747
export type MouseTool = "draw" | "move-resize";
4848

49-
type RecordingOptions = RecorderOptions & (ProgressiveUploaderOptionsWithUploadToken | ProgressiveUploaderOptionsWithAccessToken);
49+
type RecordingOptions = RecorderOptions & (ProgressiveUploaderOptionsWithUploadToken | ProgressiveUploaderOptionsWithAccessToken) & {timeslice?: number};
50+
51+
const DEFAULT_TIMESLICE = 5000;
5052

5153
export class MediaStreamComposer {
5254
private result: MediaStream | null = null;
@@ -170,7 +172,9 @@ export class MediaStreamComposer {
170172

171173
public startRecording(options: RecordingOptions) {
172174
if(!this.started) this.init();
173-
175+
176+
this._updateAudioDelay(Math.min(5000, options.timeslice || DEFAULT_TIMESLICE));
177+
174178
this.recorder = new ApiVideoMediaRecorder(this.result!, {
175179
...options,
176180
origin: {
@@ -187,7 +191,7 @@ export class MediaStreamComposer {
187191
this.recorder?.addEventListener(event, (e) => this.eventTarget.dispatchEvent(Object.assign(new Event(event), { data: (e as any).data })));
188192
});
189193

190-
this.recorder.start();
194+
this.recorder.start({ timeslice: options.timeslice || DEFAULT_TIMESLICE });
191195
}
192196

193197
public destroy() {

0 commit comments

Comments
 (0)