start method
Last updated: 2026-03-05T10:53:28.864Z
Metrics
LOC: 39
Complexity: 4
Params: 2
Signature
start(tabId, optionsOverride)
Source Code
async start(tabId, optionsOverride) {
if (state !== "inactive") {
log.warn("Recording already active");
return;
}
const opts: ScreenRecordOptions = {
...DEFAULT_SCREEN_RECORD_OPTIONS,
...optionsOverride,
};
try {
stream = await acquireStream(tabId, opts);
chunks = [];
const mimeType = mimeForCodec(opts.codec);
recorder = new MediaRecorder(stream, {
mimeType,
videoBitsPerSecond: opts.videoBitrate,
});
recorder.ondataavailable = (e: BlobEvent) => {
if (e.data.size > 0) chunks.push(e.data);
};
recorder.onerror = (e) => {
log.error("MediaRecorder error:", e);
state = "inactive";
};
recorder.start(1000); // 1 s timeslice for progressive encoding
state = "recording";
log.info(`Recording started (tab ${tabId}, codec=${opts.codec})`);
} catch (err) {
log.error("Failed to start recording:", err);
state = "inactive";
throw err;
}
},
Dependencies (Outgoing)
| Target | Type |
|---|---|
| acquireStream | calls |
| mimeForCodec | calls |
No incoming dependencies.