macOS->Microphone Permission (request permission Message won't popup)
-
QPushButton *record = new QPushButton("RECORD", this); connect(record, &QPushButton::clicked, this, [=]() { QMicrophonePermission microphonePermission; switch (qApp->checkPermission(microphonePermission)) { case Qt::PermissionStatus::Undetermined: qApp->requestPermission(microphonePermission, this, [=]() { qDebug() << "Undetermined: Microphone permission granted!";}); std::cout << std::endl; std::cout << std::endl; break; case Qt::PermissionStatus::Denied: qApp->requestPermission(microphonePermission, this, [=]() { qDebug() << "Asking permission within the Denied case";}); qWarning("Denied: Microphone permission is not granted!"); std::cout << std::endl; std::cout << std::endl; break; case Qt::PermissionStatus::Granted: // Permission already granted, perform action here QMediaCaptureSession session; QAudioInput audioInput; 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; } });
Within the Info.plist, I've written this:
<key>NSMicrophoneUsageDescription</key>
<string>We need access to your microphone to record audio for voice chat.</string>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.
-
@SlayH said in macOS->Microphone Permission (request permission Message won't popup):
nothing works
This is not a proper problem description.
What exactly does not work? -
@jsulm I mean the request message to access the microphone doesn't not appear when I click on the button which will emit the signal to start recording the audio. It just prompts in the terminal the following message: qt.permissions: Could not find permission plugin for QMicrophonePermission. Please make sure you have included the required usage description in your Info.plist
-
@SlayH said in macOS->Microphone Permission (request permission Message won't popup):
qt.permissions: Could not find permission plugin for QMicrophonePermission. Please make sure you have included the required usage description in your Info.plist
This is something you should have posted in the first message.
Do you start your app from QtCreator? -
Qt now offers cross platform PermissionRequest classes ? Maybe I of have to upgrade to Qt6 :(, so much work!
Anyway, you didn't show your project file/cmake file. Do you tell your build setup to use your own custom info.plist file ? if not it gets generated each compile anew and your changes to it won't matter
-
@J-Hilk
add_executable(client
client_main.cpp
client_main_window.cpp
client_manager.cpp
client_chat_window.cpp
chat_protocol.cpp
chat_line.cpp
)
target_link_libraries(client PRIVATE database_library)qt_add_resources(client "images"
PREFIX "/images"
FILES send_icon.png
)set(MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
set_target_properties(client PROPERTIES MACOSX_BUNDLE ON)
This is the CMake file related to the executable I am having prob ton have access to the Microphone. I did setup the Info.plist file.
-