Better error message for no mic permission

Also, change back bit rate to 128, see if it affects things.
This commit is contained in:
N-Pex 2021-03-23 12:40:06 +01:00
parent d94bcec376
commit f5587ce0c9

View file

@ -111,7 +111,7 @@
<v-container fluid fill-height> <v-container fluid fill-height>
<v-row align="center"> <v-row align="center">
<v-col> <v-col>
<div class="swipe-info">Failed to record audio</div> <div class="swipe-info">{{ errorMessage || 'Failed to record audio' }}</div>
</v-col> </v-col>
<v-col align="right"> <v-col align="right">
<v-btn icon @click.stop="cancelRecording"> <v-btn icon @click.stop="cancelRecording">
@ -179,6 +179,7 @@ export default {
recordTimer: null, recordTimer: null,
recordingLocked: false, recordingLocked: false,
recordedFile: null, recordedFile: null,
errorMessage: null
}; };
}, },
watch: { watch: {
@ -217,6 +218,7 @@ export default {
if (val) { if (val) {
// Add listeners // Add listeners
this.state = State.INITIAL; this.state = State.INITIAL;
this.errorMessage = null;
this.recordedFile = null; this.recordedFile = null;
if (this.ptt) { if (this.ptt) {
document.addEventListener("mouseup", this.mouseUp, false); document.addEventListener("mouseup", this.mouseUp, false);
@ -315,7 +317,7 @@ export default {
const MicRecorder = require("mic-recorder-to-mp3"); const MicRecorder = require("mic-recorder-to-mp3");
// Start recording. Browser will request permission to use your microphone. // Start recording. Browser will request permission to use your microphone.
this.recorder = new MicRecorder({ this.recorder = new MicRecorder({
bitRate: 32, bitRate: 128,
}); });
this.recorder this.recorder
.start() .start()
@ -326,6 +328,9 @@ export default {
}) })
.catch((e) => { .catch((e) => {
console.error(e); console.error(e);
if (e && e.name == "NotAllowedError") {
this.errorMessage = e.message;
}
this.state = State.ERROR; this.state = State.ERROR;
}); });
}, },