Getting access to front microphone on mobile device.
-
Hi. I have some trouble.
I,m trying to get data from two microphones on my Xaomi Redmi 8.
If i use code like this:
const QList<QAudioDevice> audioDevices = QMediaDevices::audioInputs();
I get only one mic and tuner in the list.
Same operation on Redmi 9 - same result.
How can i get access to second microphone? -
First, ensure that both your Redmi 8 and Redmi 9 devices actually have two physical microphones. Some phones have multiple microphones for noise cancellation or stereo recording, while others may have only one. Make sure your app has the necessary permissions to access the microphone. In Android, you need to request the RECORD_AUDIO permission in your app’s manifest file.
QMediaPlayer* player = new QMediaPlayer;
QAudioOutput* audioOutput = new QAudioOutput;
player->setAudioOutput(audioOutput);
player->setSource(QUrl::fromLocalFile("/path/to/coolsong.mp3"));
audioOutput->setVolume(50);
player->play();