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. QAudioOutput start method not supported - QT6
Forum Updated to NodeBB v4.3 + New Features

QAudioOutput start method not supported - QT6

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 2 Posters 894 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.
  • H Offline
    H Offline
    harish__rajora
    wrote on last edited by
    #1

    Is the start method not available in QT6 for QAudioOutput? It doesn't take it when I try to implement it for audio playing.

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @harish__rajora said in QAudioOutput start method not supported - QT6:

      It doesn't take it when I try to implement it for audio playing.

      What does this mean?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • H Offline
        H Offline
        harish__rajora
        wrote on last edited by
        #3

        QAudioOutput *outputstream;
        outputstream = new QAudioOutput(this);

        I want to do outputstream->start() but it doesn't happen.

        I am very new. Any help is appreciated.

        1 Reply Last reply
        0
        • Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @harish__rajora said in QAudioOutput start method not supported - QT6:

          but it doesn't happen.

          Again: what does this mean?

          Please provide some code - simply instantiating a QAudioOutput and calling start() will do nothing.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          0
          • H Offline
            H Offline
            harish__rajora
            wrote on last edited by
            #5
             file_name = QFileDialog::getOpenFileName(this, "Open a file");
                    if (!file_name.isEmpty()){
                        QLabel *fileName = findChild<QLabel*>("fileName");
                        fileName->setText(file_name);
                        cout<<file_name.toStdString();
            
                        QFile audio_file(file_name);
            
                        if(audio_file.open(QIODevice::ReadOnly)) {
                           readheader();
                            audio_data = audio_file.readAll();
                            audio_file.close();
                 
                            QDataStream audio_ds(audio_data);
                            int val = 0;
                            audio_ds>>val;
                            audio_buffer = new QBuffer(&temporary_audio_array);
            
            
                      
                            int initial_byte = 0;
            
            
            
                                 temporary_audio_array.clear();
                                 audio_buffer->reset();
                                 for(int i = initial_byte; i < initial_byte + 80000; i++)
                                       temporary_audio_array.append(audio_data[i]);
            
            
                            qDebug()<<"The size of audio_buffer is"<<audio_data.size();
                            audio_buffer->seek(0);
                            QAudioFormat format = QAudioFormat();
                            
                            cout << "Filled buffer" << endl;
                            QAudioOutput *outputstream;
                            outputstream = new QAudioOutput(this);
                            format.setSampleFormat(QAudioFormat::Int16);
                    
                            myplayer->setAudioOutput(outputstream);
                            audio_buffer->open(QIODevice::ReadWrite);
                            
                            
                            if(!audio_buffer->open(QIODevice::ReadWrite)) qDebug() << "Buffer not opened";
                                else
                                {
                                    qDebug() << "Buffer size:" << audio_buffer->size();
                                    audio_buffer->seek(0);
                                    myplayer->setSourceDevice(&audio_buffer, QUrl(file_name));
            
                                }
                          }
                      }
                  }
            

            Currently I am playing through QMultimedia but I want to do with QAudioOutput here. Please let me know everything I am doing wrong.

            1 Reply Last reply
            1
            • Christian EhrlicherC Online
              Christian EhrlicherC Online
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by Christian Ehrlicher
              #6

              What is 'mplayer' and where do you actually call QAudioOutput::start()?
              Please simplify your code or start with the example code and see if this works

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              0
              • H Offline
                H Offline
                harish__rajora
                wrote on last edited by
                #7

                There is no need to study the code. My only question is whether QT has removed the start method from QAudioOutput class?
                The example you linked in from QT5. Check QT6. https://doc.qt.io/qt-6/qaudiooutput-members.html

                1 Reply Last reply
                0
                • Christian EhrlicherC Online
                  Christian EhrlicherC Online
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  You're right. The forum search function found this: https://forum.qt.io/topic/130480/porting-qaudiodevice-to-qt6-2

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  1 Reply Last reply
                  1

                  • Login

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