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)
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 607 Views 1 Watching
  • 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 last edited by SlayH
    #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.

    jsulmJ 1 Reply Last reply
    0
    • S SlayH
      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.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on 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
      0
      • jsulmJ jsulm

        @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 last edited by SlayH
        #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

        jsulmJ 1 Reply Last reply
        0
        • S SlayH

          @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

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on 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
          1
          • S Offline
            S Offline
            SlayH
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0
            • jsulmJ jsulm

              @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 last edited by
              #6

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

              1 Reply Last reply
              0
              • J.HilkJ Offline
                J.HilkJ Offline
                J.Hilk
                Moderators
                wrote on 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
                0
                • J.HilkJ J.Hilk

                  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 last edited by SlayH
                  #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

                  • Login

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