MCPcopy
hub / github.com/CapSoftware/Cap / stopRecording

Function stopRecording

apps/chrome-extension/src/offscreen/recorder.ts:1346–1400  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1344 };
1345
1346async function stopRecording() {
1347 // A stop during the pre-roll countdown cancels the start before any frame is
1348 // captured. Resolving the countdown wait lets startRecording's
1349 // throwIfStartCanceled tear down the half-built session (streams, server
1350 // recording, spool) instead of finalizing an empty recording.
1351 if (countdownInProgress) {
1352 startCancelRequested = true;
1353 countdownResolve?.();
1354 return status;
1355 }
1356
1357 const recording = activeRecording;
1358 if (!recording) {
1359 // A stop while the start sequence is still running (capture picker
1360 // open, server round-trips pending) aborts that start; the start call
1361 // itself resolves as a cancellation.
1362 if (startInProgress) {
1363 startCancelRequested = true;
1364 }
1365 return status;
1366 }
1367
1368 stopManualChunking(recording);
1369 const now = Date.now();
1370 recording.durationMs = getRecordingDuration(recording, now);
1371 recording.lastResumedAt = null;
1372
1373 if (recording.recorder.state !== "inactive") {
1374 recording.recorder.stop();
1375 }
1376
1377 if (status.phase !== "error") {
1378 const snapshot = getCurrentUploadSnapshot();
1379 status = {
1380 phase: "uploading",
1381 videoId: recording.videoId,
1382 startedAt: recording.startedAt,
1383 durationMs: recording.durationMs,
1384 updatedAt: now,
1385 upload: snapshot.upload,
1386 uploadStatus: snapshot.uploadStatus,
1387 };
1388 broadcastStatus();
1389 void loadSettings()
1390 .then((settings) => playRecordingSound("stop-recording", settings))
1391 .catch(() => undefined);
1392 }
1393
1394 if (!recording.finalizePromise) {
1395 recording.finalizePromise = finalizeRecording(recording);
1396 void recording.finalizePromise.catch(() => undefined);
1397 }
1398
1399 return status;
1400}
1401
1402const pauseRecording = () => {
1403 const recording = activeRecording;

Callers 3

stopRecorderAfterErrorFunction · 0.70
handleRequestFunction · 0.70

Calls 8

loadSettingsFunction · 0.90
stopManualChunkingFunction · 0.85
getRecordingDurationFunction · 0.85
getCurrentUploadSnapshotFunction · 0.85
broadcastStatusFunction · 0.85
playRecordingSoundFunction · 0.85
finalizeRecordingFunction · 0.85
stopMethod · 0.65

Tested by

no test coverage detected