Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.11.1
-
None
-
Ubuntu 18.04
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.