Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. macOS->Microphone Permission (request permission Message won't popup)

macOS->Microphone Permission (request permission Message won't popup)

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 570 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SlayH
    wrote on 3 May 2024, 02:51 last edited by SlayH 5 Mar 2024, 02:55
    #1
    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.

    J 1 Reply Last reply 3 May 2024, 05:13
    0
    • S SlayH
      3 May 2024, 02:51
      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.

      J Online
      J Online
      jsulm
      Lifetime Qt Champion
      wrote on 3 May 2024, 05:13 last edited by
      #2

      @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?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply 3 May 2024, 05:20
      0
      • J jsulm
        3 May 2024, 05:13

        @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?

        S Offline
        S Offline
        SlayH
        wrote on 3 May 2024, 05:20 last edited by SlayH 5 Mar 2024, 05:31
        #3

        @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

        J 1 Reply Last reply 3 May 2024, 05:26
        0
        • S SlayH
          3 May 2024, 05:20

          @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

          J Online
          J Online
          jsulm
          Lifetime Qt Champion
          wrote on 3 May 2024, 05:26 last edited by
          #4

          @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?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          S 1 Reply Last reply 3 May 2024, 05:55
          1
          • S Offline
            S Offline
            SlayH
            wrote on 3 May 2024, 05:31 last edited by
            #5

            @jsulm NO, I started it from vsCode. I used CMake to build it there.

            1 Reply Last reply
            0
            • J jsulm
              3 May 2024, 05:26

              @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?

              S Offline
              S Offline
              SlayH
              wrote on 3 May 2024, 05:55 last edited by
              #6

              @jsulm I just started it from QtCreator and the same problem occurred.

              1 Reply Last reply
              0
              • J Offline
                J Offline
                J.Hilk
                Moderators
                wrote on 3 May 2024, 06:08 last edited by
                #7

                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


                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                S 1 Reply Last reply 3 May 2024, 06:12
                0
                • J J.Hilk
                  3 May 2024, 06:08

                  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

                  S Offline
                  S Offline
                  SlayH
                  wrote on 3 May 2024, 06:12 last edited by SlayH 5 Mar 2024, 06:12
                  #8

                  @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.

                  1 Reply Last reply
                  0
                  • S SlayH has marked this topic as solved on 8 May 2024, 17:08

                  8/8

                  3 May 2024, 06:12

                  • Login

                  • Login or register to search.
                  8 out of 8
                  • First post
                    8/8
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved