Fixed recording on RecordMp3 element to work (#17)

This commit is contained in:
Ceferino Patino 2022-03-31 07:53:37 -05:00 committed by GitHub
commit 4a2d04b3a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 14 deletions

View file

@ -26,6 +26,6 @@ version-resolver:
- 'patch'
default: patch
template: |
## Changes
# Changes
$CHANGES

View file

@ -0,0 +1,25 @@
## Defining .env file
---
### React client environment variables
- REACT_APP_API_ROOT: Domain root for react app api
- REACT_APP_DOMAIN_ROOT: Domain root for react app
- BUILD_PATH: Path for client build folder
### Courier client
- COURIER_AUTH_TOKEN: Authorization token for courier client
### Node environment variables
- NODE_ENV: Node environment
- PORT: Default node port
### Production database information
- DB_USERNAME: Production database username
- DB_PASSWORD: Production database password
- DB_HOST: Production database host ip
- DB_NAME: Production database name

View file

@ -25,7 +25,7 @@ function RecordMp3() {
.get(
`${
process.env.REACT_APP_DOMAIN_ROOT
}/public/audio/${Cookies.get('token')}.mp3`,
}/public/audio/${Cookies.get('userID')}.mp3`,
{
responseType: 'blob',
}
@ -41,7 +41,6 @@ function RecordMp3() {
}, []);
function togglePlay() {
console.log(uploadedFile);
if (audio && !audio.ended) {
audio.pause();
audio.currentTime = 0;
@ -53,14 +52,13 @@ function RecordMp3() {
}
}
async function record() {
function record() {
if (recording) {
console.log('Stopped Recording');
setRecording(() => false);
recorder
.stop()
.getMp3()
.then(([buffer, blob]) => {
setRecording(() => false);
setUploadedFile(() => {
return new File(buffer, 'userAudio.mp3', {
type: blob.type,
@ -69,14 +67,10 @@ function RecordMp3() {
});
});
} else {
recorder
.start()
.then(() => {
setRecording(() => true);
})
.catch((e) => {
console.error(e);
});
setRecording(() => true);
recorder.start().catch((e) => {
console.error(e);
});
}
}