From 7eab81e973e9d03ce3295e0a1a8fb8e3e06ff236 Mon Sep 17 00:00:00 2001 From: Ben Allen Date: Sat, 28 Mar 2020 01:41:57 +0000 Subject: [PATCH] gets the damn list once now coz screw refreshing --- src/showplanner/index.tsx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/showplanner/index.tsx b/src/showplanner/index.tsx index 5dd594c..d281221 100644 --- a/src/showplanner/index.tsx +++ b/src/showplanner/index.tsx @@ -292,15 +292,26 @@ function LibraryColumn() { function MicControl() { const state = useSelector((state: RootState) => state.mixer.mic); const [gotMicList, setGotMicList] = useState(false); + var micList: MediaDeviceInfo[] = [] const dispatch = useDispatch(); if (gotMicList == false){ - console.log(navigator.mediaDevices.enumerateDevices()) - setGotMicList(true) + navigator.mediaDevices.enumerateDevices() + .then((devices)=>{ + micList = reduceToInputs(devices) + setGotMicList(true) + }) + .catch(() => {console.log("Could not fetch devices");}) } - function reduceToInputs(){ - + function reduceToInputs(devices:MediaDeviceInfo[]){ + var temp: MediaDeviceInfo[] = [] + devices.forEach((device)=>{ + if (device.kind == "audioinput") { + temp.push(device) + } + }) + return temp } return (