Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-69402

QMediaRecorder::StoppedState with non-finished recording

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.12.0
    • 5.11.1
    • Multimedia
    • None
    • Ubuntu 18.04
    • Linux/X11

    Description

      #include <QtCore/QDir>
      #include <QtCore/QFileInfo>
      #include <QtCore/QTimer>
      #include <QtCore/QUrl>
      #include <QtMultimedia/QAudioRecorder>
      #include <QtWidgets/QApplication>
      #include <QtWidgets/QMainWindow>
      
      struct main_window : QMainWindow
      {
          main_window()
          {
              recorder_.setOutputLocation( QUrl::fromLocalFile( filepath_ ) );
              recorder_.record();
      
              startTimer( 2000 );
      
              connect( &recorder_, &QAudioRecorder::stateChanged, this, &main_window::on_state_changed );
          }
      
          void timerEvent( QTimerEvent* /*e*/ ) override
          {
              if( recorder_.state() == QAudioRecorder::RecordingState )
              {
                  recorder_.stop();
              }
              else
              {
                  qInfo() << QFileInfo( filepath_ ).size();
                  QDir().remove( filepath_ );
      
                  close();
              }
          }
      
          void on_state_changed( QAudioRecorder::State state )
          {
              if( state == QAudioRecorder::StoppedState )
                  qInfo() << QFileInfo( filepath_ ).size();
          }
      
          const QString  filepath_ { "/tmp/_test_qaudiorecorder" };
          QAudioRecorder recorder_;
      };
      
      int main( int argc, char** argv )
      {
          QApplication a { argc, argv };
      
          main_window w;
          w.show();
      
          return a.exec();
      }
      

      17347
      19662

      While the documentation says:

      QMediaRecorder::StoppedState: The recorder is not active. If this is the state after recording then the actual created recording has finished being written to the final location and is ready on all platforms except on Android. On Android, due to platform limitations, there is no way to be certain that the recording has finished writing to the final location.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            valentyn.doroshchuk Valentyn Doroshchuk
            igornikitin Igor
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes