can open specific mic, action must be repeatable

This commit is contained in:
Ben Allen 2020-03-28 02:06:55 +00:00
parent 5ad68a312e
commit 81138333ba
2 changed files with 6 additions and 8 deletions

View file

@ -510,7 +510,7 @@ export const setVolume = (
};
};
export const openMicrophone = (): AppThunk => async (dispatch, getState) => {
export const openMicrophone = (micID:string): AppThunk => async (dispatch, getState) => {
if (getState().mixer.mic.open) {
return;
}
@ -523,6 +523,7 @@ export const openMicrophone = (): AppThunk => async (dispatch, getState) => {
try {
micMedia = await navigator.mediaDevices.getUserMedia({
audio: {
deviceId:{exact: micID},
echoCancellation: false,
autoGainControl: false,
noiseSuppression: false,

View file

@ -321,7 +321,7 @@ function MicControl() {
<h2>Microphone</h2>
<button
disabled={state.open}
onClick={() => dispatch(MixerState.openMicrophone())}
onClick={() => dispatch(MixerState.openMicrophone(micSource))}
>
Open
</button>
@ -332,13 +332,10 @@ function MicControl() {
value={micSource}
onChange={e => setMicSource(e.target.value)}
>
<option value={"None"} disabled>
Choose a microphone
</option>
<option value={"None"} disabled label="Choose a microphone"></option>
{
micList.map(function(device) {
console.log("when rendering list: ", micList)
return <option value={device.deviceId}>{device.label}</option>;
micList.map(e => {
return <option value={e.deviceId}>{e.label}</option>;
})
}
</select>