Updated audio recorder example with screenshot and correct information.
authorJonas Rabbe <jonas.rabbe@nokia.com>
Mon, 13 Feb 2012 22:41:51 +0000 (08:41 +1000)
committerQt by Nokia <qt-info@nokia.com>
Tue, 14 Feb 2012 01:02:51 +0000 (02:02 +0100)
Change-Id: Ibf0dc8df55f20988a949e49b1b434710373f0095
Reviewed-by: Ling Hu <ling.hu@nokia.com>
Reviewed-by: Mithra Pattison <mithra.pattison@nokia.com>
Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
doc/src/examples/audiorecorder.qdoc
doc/src/images/audiorecorder.png [new file with mode: 0644]

index 4145f9a..6565daa 100644 (file)
 
 
 
-    This example shows how to create a simple audio recorder using the QtMobility
+    This example shows how to create a simple audio recorder using the Qt
     Multimedia API.
 
-    We can easily setup the capture when we create the objects using a
-    QMediaRecorder initialized with a QAudioCaptureSource object.
+    We display a window for the user to select the appropriate audio input,
+    codec, container, and sample rate. Allow a setting of either quality or
+    bitrate. Finally, the output file can be selected and recording can be
+    started.
+
+    The lists are setup using the \l{QAudioRecorder::audioInputs()}{audioInputs()},
+    \l{QAudioRecorder::supportedAudioCodecs()}{supportedAudioCodecs()},
+    \l{QAudioRecorder::supportedContainers()}{supportedContainers()},
+    \l{QAudioRecorder::supportedContainers()}{supportedContainers()}, and
+    \l{QAudioRecorder::supportedAudioSampleRates()}{supportedAudioSampleRates()}
+    methods. The quality slider is setup from 0 (zero) to
+    \l{QtMultimedia::VeryHighQuality} with a default value of
+    \l{QtMultimedia::NormalQuality}, while the bitrates are hardcoded
+    into the list.
+
+    \image audiorecorder.png
+
+    To record audio we simply create a QAudioRecorder object.
+
+    \code
+    audioRecorder = new QAudioRecorder(this);
+    \endcode
+
+    And setup the lists as described above. The text on the record and pause
+    buttons are toggled depending on the \l{QMediaRecorder::State}{state} of
+    the \c audioRecorder object. This means that if the state is
+    \l{QMediaRecorder::StoppedState} then the button text will be "Record" and
+    "Pause". In \l{QMediaRecorder::RecordingState} the record button will have
+    the text "Stop", and in \l{QMediaRecorder::PausedState} the pause button
+    will have the text "Resume".
+
+    Pressing the buttons will also result in a toggle based on the state. If
+    recording is stopped, then pressing the record button will setup the
+    \l{QAudioEncoderSettings} based on the values of the selection lists,
+    will set the encoding settings and container on the \c audioRecorder
+    object, and start recording using the
+    \l{QMediaRecorder::record()}{record()} method.
+
+    \code
+        QAudioEncoderSettings settings;
+        settings.setCodec(boxValue(ui->audioCodecBox).toString());
+        settings.setSampleRate(boxValue(ui->sampleRateBox).toInt());
+        settings.setBitRate(boxValue(ui->bitrateBox).toInt());
+        settings.setQuality(QtMultimedia::EncodingQuality(ui->qualitySlider->value()));
+        settings.setEncodingMode(ui->constantQualityRadioButton->isChecked() ?
+                                 QtMultimedia::ConstantQualityEncoding :
+                                 QtMultimedia::ConstantBitRateEncoding);
+
+        QString container = boxValue(ui->containerBox).toString();
+
+        audioRecorder->setEncodingSettings(settings, QVideoEncoderSettings(), container);
+        audioRecorder->record();
+    \endcode
+
+    While recording, the status bar of the application is updated with duration information
+    from the \l{QMediaRecorder::durationChanged()}{durationChanged} signal from the
+    \c audioRecorder object.
+
+    \code
+    ui->statusbar->showMessage(tr("Recorded %1 sec").arg(duration / 1000));
+    \endcode
 
-    \snippet    snippets/multimedia-snippets/audiorecorder.cpp create-objs-1
 
-    Then we set up the display of a list of available sources to use
-
-    \snippet    snippets/multimedia-snippets/audiorecorder.cpp device-list
-
-    And available codecs
-
-    \snippet    snippets/multimedia-snippets/audiorecorder.cpp codec-list
-
-    We display a dialog for the user to select the appropriate codec and the
-    input device to capture. Once selected we can use user interface objects
-    like buttons to start and stop the recording and display elapsed time.
-
-    \snippet    snippets/multimedia-snippets/audiorecorder.cpp get-device
-
-    Then use signals to indicate a change to the output filename, the codec
-    and the audio source.
-
-    When the button to record is pushed the toggleRecord() slot will start
-    or stop the recording process using the \l{QMediaRecorder::record()}
-    and \l{QMediaRecorder::stop()} functions of the QMediaRecorder object.
-
-    \snippet    snippets/multimedia-snippets/audiorecorder.cpp toggle-record
 
 
 */
diff --git a/doc/src/images/audiorecorder.png b/doc/src/images/audiorecorder.png
new file mode 100644 (file)
index 0000000..6643bf3
Binary files /dev/null and b/doc/src/images/audiorecorder.png differ