import { Audio } from 'expo-av'; import { RecordingInput } from 'expo-av/build/Audio/Recording.types'; import React, { useCallback, useEffect, useState } from 'react'; import { Text, View } from 'react-native'; import ListButton from '../../components/ListButton'; type Props = { recordingObject?: Audio.Recording; }; function AudioInputSelector({ recordingObject }: Props) { const [availableInputs, setAvailableInputs] = useState([]); const [currentInput, setCurrentInput] = useState(null); const checkInputs = useCallback(async () => { if (recordingObject) { const availInputs = await recordingObject.getAvailableInputs(); setAvailableInputs(availInputs); const curtInput = await recordingObject.getCurrentInput(); setCurrentInput(curtInput); } }, [recordingObject]); useEffect(() => { checkInputs(); }, [checkInputs]); return ( Recording Inputs: {availableInputs.length ? ( availableInputs.map((input) => { const isSelected = input.uid === currentInput?.uid; const title = input.name; return ( { await recordingObject?.setInput(input.uid); checkInputs(); }} /> ); }) ) : ( Inputs cannot be populated until a recording object is created. Begin recording to view inputs. )} ); } export default AudioInputSelector;