Fixed recording on RecordMp3 element to work (#17)
This commit is contained in:
parent
b2e727e7bf
commit
4a2d04b3a0
3 changed files with 33 additions and 14 deletions
2
.github/release-drafter.yml
vendored
2
.github/release-drafter.yml
vendored
|
|
@ -26,6 +26,6 @@ version-resolver:
|
||||||
- 'patch'
|
- 'patch'
|
||||||
default: patch
|
default: patch
|
||||||
template: |
|
template: |
|
||||||
## Changes
|
# Changes
|
||||||
|
|
||||||
$CHANGES
|
$CHANGES
|
||||||
|
|
|
||||||
25
README.md
25
README.md
|
|
@ -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
|
||||||
|
|
@ -25,7 +25,7 @@ function RecordMp3() {
|
||||||
.get(
|
.get(
|
||||||
`${
|
`${
|
||||||
process.env.REACT_APP_DOMAIN_ROOT
|
process.env.REACT_APP_DOMAIN_ROOT
|
||||||
}/public/audio/${Cookies.get('token')}.mp3`,
|
}/public/audio/${Cookies.get('userID')}.mp3`,
|
||||||
{
|
{
|
||||||
responseType: 'blob',
|
responseType: 'blob',
|
||||||
}
|
}
|
||||||
|
|
@ -41,7 +41,6 @@ function RecordMp3() {
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
function togglePlay() {
|
function togglePlay() {
|
||||||
console.log(uploadedFile);
|
|
||||||
if (audio && !audio.ended) {
|
if (audio && !audio.ended) {
|
||||||
audio.pause();
|
audio.pause();
|
||||||
audio.currentTime = 0;
|
audio.currentTime = 0;
|
||||||
|
|
@ -53,14 +52,13 @@ function RecordMp3() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function record() {
|
function record() {
|
||||||
if (recording) {
|
if (recording) {
|
||||||
console.log('Stopped Recording');
|
setRecording(() => false);
|
||||||
recorder
|
recorder
|
||||||
.stop()
|
.stop()
|
||||||
.getMp3()
|
.getMp3()
|
||||||
.then(([buffer, blob]) => {
|
.then(([buffer, blob]) => {
|
||||||
setRecording(() => false);
|
|
||||||
setUploadedFile(() => {
|
setUploadedFile(() => {
|
||||||
return new File(buffer, 'userAudio.mp3', {
|
return new File(buffer, 'userAudio.mp3', {
|
||||||
type: blob.type,
|
type: blob.type,
|
||||||
|
|
@ -69,14 +67,10 @@ function RecordMp3() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
recorder
|
setRecording(() => true);
|
||||||
.start()
|
recorder.start().catch((e) => {
|
||||||
.then(() => {
|
console.error(e);
|
||||||
setRecording(() => true);
|
});
|
||||||
})
|
|
||||||
.catch((e) => {
|
|
||||||
console.error(e);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Reference in a new issue