QMediaRecorder Class
The QMediaRecorder class is used for the recording of media content. More...
| Header: | #include <QMediaRecorder> |
| qmake: | QT += multimedia |
| Inherits: | QObject and QMediaBindableInterface |
| Inherited By: |
Public Types
| enum | Error { NoError, ResourceError, FormatError, OutOfSpaceError } |
| enum | State { StoppedState, RecordingState, PausedState } |
| enum | Status { UnavailableStatus, UnloadedStatus, LoadingStatus, LoadedStatus, StartingStatus, …, FinalizingStatus } |
Properties
|
|
Public Functions
| QUrl | actualLocation() const |
| qint64 | duration() const |
| bool | isMetaDataAvailable() const |
| bool | isMetaDataWritable() const |
| bool | isMuted() const |
| QUrl | outputLocation() const |
| bool | setOutputLocation(const QUrl &location) |
| QMediaRecorder::State | state() const |
| QMediaRecorder::Status | status() const |
| qreal | volume() const |
Public Slots
Signals
| void | actualLocationChanged(const QUrl &location) |
| void | durationChanged(qint64 duration) |
| void | metaDataAvailableChanged(bool available) |
| void | metaDataWritableChanged(bool writable) |
| void | mutedChanged(bool muted) |
| void | stateChanged(QMediaRecorder::State state) |
| void | statusChanged(QMediaRecorder::Status status) |
| void | volumeChanged(qreal volume) |
Detailed Description
The QMediaRecorder class is a high level media recording class. It's not intended to be used alone but for accessing the media recording functions of other media objects, like QRadioTuner, or QCamera.
recorder = new QMediaRecorder(camera); QAudioEncoderSettings audioSettings; audioSettings.setCodec("audio/amr"); audioSettings.setQuality(QMultimedia::HighQuality); recorder->setAudioSettings(audioSettings); recorder->setOutputLocation(QUrl::fromLocalFile(fileName)); recorder->record();
See also QAudioRecorder.
Member Type Documentation
enum QMediaRecorder::Error
| Constant | Value | Description |
|---|---|---|
QMediaRecorder::NoError | 0 | No Errors. |
QMediaRecorder::ResourceError | 1 | Device is not ready or not available. |
QMediaRecorder::FormatError | 2 | Current format is not supported. |
QMediaRecorder::OutOfSpaceError | 3 | No space left on device. |
enum QMediaRecorder::State
| Constant | Value | Description |
|---|---|---|
QMediaRecorder::StoppedState | 0 | 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. |
QMediaRecorder::RecordingState | 1 | The recording is requested. |
QMediaRecorder::PausedState | 2 | The recorder is paused. |
enum QMediaRecorder::Status
| Constant | Value | Description |
|---|---|---|
QMediaRecorder::UnavailableStatus | 0 | The recorder is not available or not supported by connected media object. |
QMediaRecorder::UnloadedStatus | 1 | The recorder is avilable but not loaded. |
QMediaRecorder::LoadingStatus | 2 | The recorder is initializing. |
QMediaRecorder::LoadedStatus | 3 | The recorder is initialized and ready to record media. |
QMediaRecorder::StartingStatus | 4 | Recording is requested but not active yet. |
QMediaRecorder::RecordingStatus | 5 | Recording is active. |
QMediaRecorder::PausedStatus | 6 | Recording is paused. |
QMediaRecorder::FinalizingStatus | 7 | Recording is stopped with media being finalized. |
Property Documentation
actualLocation : const QUrl
This property holds the actual location of the last media content.
The actual location is usually available after recording starts, and reset when new location is set or new recording starts.
Access functions:
| QUrl | actualLocation() const |
Notifier signal:
| void | actualLocationChanged(const QUrl &location) |
duration : const qint64
This property holds the recorded media duration in milliseconds.
Access functions:
| qint64 | duration() const |
Notifier signal:
| void | durationChanged(qint64 duration) |
metaDataAvailable : const bool
This property holds whether access to a media object's meta-data is available.
If this is true there is meta-data available, otherwise there is no meta-data available.
Access functions:
| bool | isMetaDataAvailable() const |
Notifier signal:
| void | metaDataAvailableChanged(bool available) |
metaDataWritable : const bool
This property holds whether a media object's meta-data is writable.
If this is true the meta-data is writable, otherwise the meta-data is read-only.
Access functions:
| bool | isMetaDataWritable() const |
Notifier signal:
| void | metaDataWritableChanged(bool writable) |
muted : bool
This property holds whether a recording audio stream is muted.
Access functions:
| bool | isMuted() const |
| void | setMuted(bool muted) |
Notifier signal:
| void | mutedChanged(bool muted) |
outputLocation : QUrl
This property holds the destination location of media content.
Setting the location can fail, for example when the service supports only local file system locations but a network URL was passed. If the service does not support media recording this setting the output location will always fail.
The location can be relative or empty; in this case the recorder uses the system specific place and file naming scheme. After recording has stated, QMediaRecorder::outputLocation() returns the actual output location.
Access functions:
| QUrl | outputLocation() const |
| bool | setOutputLocation(const QUrl &location) |
state : const QMediaRecorder::State
This property holds the current state of the media recorder.
The state property represents the user request and is changed synchronously during record(), pause() or stop() calls. Recorder state may also change asynchronously when recording fails.
Access functions:
| QMediaRecorder::State | state() const |
Notifier signal:
| void | stateChanged(QMediaRecorder::State state) |
status : const QMediaRecorder::Status
This property holds the current status of the media recorder.
The status is changed asynchronously and represents the actual status of media recorder.
Access functions:
| QMediaRecorder::Status | status() const |
Notifier signal:
| void | statusChanged(QMediaRecorder::Status status) |
volume : qreal
This property holds the current recording audio volume.
The volume is scaled linearly from 0.0 (silence) to 1.0 (full volume). Values outside this range will be clamped.
The default volume is 1.0.
UI volume controls should usually be scaled nonlinearly. For example, using a logarithmic scale will produce linear changes in perceived loudness, which is what a user would normally expect from a volume control. See QAudio::convertVolume() for more details.
Access functions:
| qreal | volume() const |
| void | setVolume(qreal volume) |
Notifier signal:
| void | volumeChanged(qreal volume) |