Problem with Microphone Permission Request using QMicrophonePermission and info.plist file
-
QPushButton *record = new QPushButton("RECORD", this); connect(record, &QPushButton::clicked, this, [=]() { QMicrophonePermission microphonePermission; switch (qApp->checkPermission(microphonePermission)) { case Qt::PermissionStatus::Undetermined: // Request permission asynchronously qApp->requestPermission(microphonePermission, [this]() { // Permission granted, perform action here qDebug() << "Microphone permission granted!"; std::cout << std::endl; std::cout << std::endl; }); break; case Qt::PermissionStatus::Denied: // Handle denied permission state appropriately qApp->requestPermission(microphonePermission, [this]() { // Permission granted, perform action here qDebug() << "Asking permission within the Denied case!"; std::cout << std::endl; std::cout << std::endl; }); qWarning("Microphone permission is not granted!"); std::cout << std::endl; std::cout << std::endl; // Display a message to the user or provide guidance break; case Qt::PermissionStatus::Granted: // Permission already granted, perform action here QMediaCaptureSession session; QAudioInput audioInput; audioInput.device(); session.setAudioInput(&audioInput); QMediaRecorder recorder; session.setRecorder(&recorder); recorder.setQuality(QMediaRecorder::HighQuality); recorder.setOutputLocation(QUrl::fromLocalFile("test.mp3")); recorder.record(); qDebug() << "Recording started!"; std::cout << std::endl; std::cout << std::endl; break; } });
The info.plist file is as follow. The 2 last permission are related to the microphone.
code_text
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>client</string>
<key>CFBundleGetInfoString</key>
<string></string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string></string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLongVersionString</key>
<string></string>
<key>CFBundleName</key>
<string></string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string></string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string></string>
<key>CSResourcesFileMapped</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string></string>
<key>NSMicrophoneUsageDescription</key>
<string>The microphone is used to record voice memos.</string>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>The Bluetooth is used to record voice memos.</string>
</dict>
</plist>code_text
Hello everyone, I have been trying to grant persmission to use the microphone but in vain. I have used QMicrophonePermission to check the permission and request it if not granted. I have also declared the permission in the info.plist file but nothing works. A little help would be much appreciated from anyone who has a vague idea about it.
-
J jsulm moved this topic from Announcements on