don't request mic access until threshold initially changed

practiced-songs
Matthew Huntington 2 years ago
parent 986058ecb1
commit 3bff27a77d

@ -77,6 +77,8 @@
this.running = true;
this.intervalID = setInterval(()=>{
if(this.micLevel > -1){
const array = new Uint8Array(this.analyser.frequencyBinCount);
this.analyser.getByteFrequencyData(array);
const arraySum = array.reduce((a, value) => a + value, 0);
@ -89,6 +91,8 @@
this.micThresholdExceeded = false;
}
}
this.totalSeconds = getAccumulatedSeconds(Date.now(), this.startTime) - this.secondsToSubtract + this.savedPreviousSeconds;
window.localStorage.setItem('lastTotalSeconds', this.totalSeconds);
@ -112,12 +116,10 @@
this.savedPreviousSeconds = this.totalSeconds;
this.secondsToSubtract = 0;
window.localStorage.setItem('lastTotalSeconds', this.totalSeconds);
}
},
mounted() {
axios.get(import.meta.env.VITE_PRACTICE_TRACKER_API_URL+'categories').then((response)=>{
this.categories = response.data
})
activateMic(){
if(this.micThreshold > -1){
navigator.mediaDevices.getUserMedia({
audio: true
@ -141,6 +143,15 @@
});
}
}
},
mounted() {
axios.get(import.meta.env.VITE_PRACTICE_TRACKER_API_URL+'categories').then((response)=>{
this.categories = response.data
})
}
}
</script>
@ -150,7 +161,8 @@
<em>
{{formatTime(totalSeconds)}}
</em>
Mic Threshold (current level: {{Math.round(micLevel)}}): <input type="number" v-model="micThreshold"/>
Mic Threshold (current level: {{Math.round(micLevel)}}):
<input type="number" @change="activateMic" v-model="micThreshold"/>
<button :disabled="running" @click="start">Start</button>
<button :disabled="!running" @click="stop">Stop</button>
<button :disabled="running || totalSeconds === 0" @click="reset">Reset</button>

Loading…
Cancel
Save