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'
|
||||
default: patch
|
||||
template: |
|
||||
## 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(
|
||||
`${
|
||||
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,12 +67,8 @@ function RecordMp3() {
|
|||
});
|
||||
});
|
||||
} else {
|
||||
recorder
|
||||
.start()
|
||||
.then(() => {
|
||||
setRecording(() => true);
|
||||
})
|
||||
.catch((e) => {
|
||||
recorder.start().catch((e) => {
|
||||
console.error(e);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue