-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically stop recording after a minute #44
Conversation
jekuaitk
commented
Aug 28, 2024
•
edited
Loading
edited
- Adds automatic recording stop after a minute
- Adds messages
volumeInterval = setInterval(volumeCallback, 100); | ||
} | ||
|
||
setTimeout(durationChecker, 60 * 1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a const
with the timeout value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had not seen that it returned a (unique) number.
While wondering why it does so, it occurred to me that if a user manually stops a recording and for whatever reason decides to do it over the timeout
will stop the next recording at essentially any random time.
So we do indeed need to keep this timeout value (id) - and clear it (cf. https://developer.mozilla.org/en-US/docs/Web/API/clearTimeout) if a user manually stops a recording.
durationChecker = () => { | ||
// Check if recording is still going. | ||
if (isRecording()) { | ||
toggleButton.click(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be a good idea to tell the user that the recording has been stopped automatically. Our designer can design a message element that you can pass to showElement
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea.
4bf64b5
to
161eea8
Compare
hideElement(stopRecordingMessageElement); | ||
showElement(automaticallyStoppedRecordingMessageElement); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make sure that more than one message is never shown, I suggest adding a showMessage
function that hides all but one message:
const showMessage(message) {
hideElement(startRecordingMessageElement);
hideElement(stopRecordingMessageElement);
…
showElement(message);
}
adding the message elements to an object (rather than having a variable for each) will make this much easier:
const messages = {
'start_recording': document.querySelector("#start_recording_message"),
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.