AVInputPickerInteraction
An object that presents the system’s audio input picker so people can choose which microphone to use for recording audio.
Declaration
@MainActor class AVInputPickerInteractionOverview
People expect the microphone they chose to be the one your app records with. Add an input picker interaction to a view, and your app presents the same picker the system uses, listing the audio inputs available at that moment.
Create an interaction with init(audioSession:) to pick inputs for a specific audio session, or with init() to use the shared session. Pass a session that records, or that you switch to recording, because a session in any other mode produces an empty list of inputs. Add the interaction to a view the way you add any UIInteraction, then call present() from the control that offers input selection. Call dismiss() to take the picker away, and read isPresented to find out whether it’s onscreen.
Set delegate to a AVInputPickerInteraction.Delegate to learn when the picker begins and finishes presenting, and when it begins and finishes dismissing. The interaction reports those transitions around its own presentation, so an app that dims its interface while someone chooses an input has a place to do that work.