Skip to content

Commit 8475918

Browse files
authored
🤖 Merge PR DefinitelyTyped#73805 [recordrtc] accept array of MediaStream in RecordRTC constructor by @KuSh
1 parent 3542593 commit 8475918

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

‎types/recordrtc/index.d.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,10 @@ declare namespace RecordRTC {
302302
}
303303

304304
declare class RecordRTC {
305-
constructor(stream: MediaStream | HTMLCanvasElement | HTMLVideoElement | HTMLElement, options?: RecordRTC.Options);
305+
constructor(
306+
stream: MediaStream | MediaStream[] | HTMLCanvasElement | HTMLVideoElement | HTMLElement,
307+
options?: RecordRTC.Options,
308+
);
306309

307310
/** start the recording */
308311
startRecording(): void;

‎types/recordrtc/recordrtc-tests.ts‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,48 @@ navigator.mediaDevices.getUserMedia({ audio: true, video: true }).then(stream =>
5050
StereoAudioRecorder.onAudioProcessStarted();
5151
});
5252

53+
Promise.all([
54+
navigator.mediaDevices.getUserMedia({ audio: true, video: true }),
55+
navigator.mediaDevices.getDisplayMedia({ audio: true, video: true }),
56+
]).then(streams => {
57+
const instance = new RecordRTC(streams, {
58+
type: "video",
59+
disableLogs: true,
60+
bufferSize: 2048,
61+
ondataavailable: (blob: Blob) => {
62+
console.log(blob);
63+
},
64+
onTimeStamp: (timestamp: number, timestamps: number[]) => {
65+
console.log(timestamp, timestamps);
66+
},
67+
previewStream: (stream: MediaStream) => {
68+
console.log(stream);
69+
},
70+
});
71+
72+
instance.stopRecording(() => {
73+
const blob = instance.getBlob();
74+
});
75+
76+
// $ExpectType State
77+
instance.getState();
78+
79+
// $ExpectType { onRecordingStopped: (callback: () => void) => void; }
80+
instance.setRecordingDuration(1);
81+
82+
const fiveMinutes = 5 * 1000 * 60;
83+
// $ExpectType void
84+
instance.setRecordingDuration(fiveMinutes, () => {});
85+
86+
// $ExpectType void
87+
instance.getDataURL(dataURL => {
88+
console.log({ dataURL });
89+
});
90+
91+
// $ExpectType void
92+
instance.setRecordingDuration(fiveMinutes).onRecordingStopped(() => {});
93+
});
94+
5395
const canvas = document.querySelector("canvas")!;
5496

5597
const instance2 = new RecordRTC(canvas, {

0 commit comments

Comments
 (0)