Skip to content

Commit

Permalink
add long recording option
Browse files Browse the repository at this point in the history
  • Loading branch information
gferraro committed Oct 16, 2024
1 parent 714cc2d commit f2c5247
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions static/js/audiorecording.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
"use strict";
enum AudioMode {
Audio = 0,
Thermal = 1,
Audio = 1,
Thermal = 0,
}

enum AudioStatus {
Ready = 1,
WaitingToTakeTestRecording = 2,
TakingTestRecording = 3,
Recording = 4,
TakingLongRecording = 5,
WaitingToTakeLongRecording = 6,
}
class AudioState {
constructor(
Expand Down Expand Up @@ -49,22 +51,38 @@ async function getAudioStatus() {
statusText = "";
enableRecButtons();
}
} else if (state == AudioStatus.WaitingToTakeTestRecording) {
} else if (
state == AudioStatus.WaitingToTakeTestRecording ||
state == AudioStatus.WaitingToTakeLongRecording
) {
countdown = 2;
audioState.lastState = state;
statusText = "Test Recording Pending";
if (state == AudioStatus.WaitingToTakeTestRecording) {
statusText = "Test Recording Pending";
} else {
statusText = "5 Minute Recording Pending";
}
if (!audioState.intervalId) {
audioState.startPolling();
disableRecButtons();
}
} else if (state == AudioStatus.TakingTestRecording) {
} else if (
state == AudioStatus.TakingTestRecording ||
state == AudioStatus.TakingLongRecording
) {
audioState.lastState = state;

let recType = "Test";
if (state == AudioStatus.TakingLongRecording) {
recType = "5 Minute";
}
if (countdown == 0) {
statusText = "Taking Test Recording";
statusText = `Taking ${recType} Recording`;
} else {
statusText = `Taking Test Recording in ${countdown}s`;
statusText = `Taking ${recType} Recording in ${countdown}s`;
countdown -= 1;
}

if (!audioState.intervalId) {
audioState.startPolling();
disableRecButtons();
Expand Down Expand Up @@ -135,7 +153,7 @@ async function recordingAPICall(checkResponse: boolean) {
if (checkResponse) {
xmlHttp.onload = async function () {
if (xmlHttp.status == 200) {
success = xmlHttp.responseText == '"Asked for a test recording"\n';
success = xmlHttp.responseText == '"Asked for a 5 minute recording"\n';
if (!success) {
enableRecButtons();
updateAudioError(xmlHttp);
Expand Down

0 comments on commit f2c5247

Please sign in to comment.