CopperSpice API  1.9.1
QMediaRecorder Class Reference

The QMediaRecorder class is used for the recording of media content. More...

Inheritance diagram for QMediaRecorder:
QObject QMediaBindableInterface QAudioRecorder

Public Types

enum  Error
 
enum  State
 
enum  Status
 

Public Signals

void actualLocationChanged (const QUrl &location)
 
void availabilityChanged (bool available)
 
void availabilityChanged (QMultimedia::AvailabilityStatus availability)
 
void durationChanged (qint64 duration)
 
void error (QMediaRecorder::Error error)
 
void metaDataAvailableChanged (bool available)
 
void metaDataChanged ()
 
void metaDataChanged (const QString &key, const QVariant &value)
 
void metaDataWritableChanged (bool writable)
 
void mutedChanged (bool muted)
 
void stateChanged (QMediaRecorder::State state)
 
void statusChanged (QMediaRecorder::Status status)
 
void volumeChanged (qreal volume)
 
- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 

Public Slots

void pause ()
 
void record ()
 
void setMuted (bool muted)
 
void setVolume (qreal volume)
 
void stop ()
 
- Public Slots inherited from QObject
void deleteLater ()
 

Public Methods

 QMediaRecorder (QMediaObject *mediaObject, QObject *parent=nullptr)
 
 ~QMediaRecorder ()
 
QUrl actualLocation () const
 
QString audioCodecDescription (const QString &codecName) const
 
QAudioEncoderSettings audioSettings () const
 
QMultimedia::AvailabilityStatus availability () const
 
QStringList availableMetaData () const
 
QString containerDescription (const QString &format) const
 
QString containerFormat () const
 
qint64 duration () const
 
Error error () const
 
QString errorString () const
 
bool isAvailable () const
 
bool isMetaDataAvailable () const
 
bool isMetaDataWritable () const
 
bool isMuted () const
 
QMediaObjectmediaObject () const override
 
QVariant metaData (const QString &key) const
 
QUrl outputLocation () const
 
void setAudioSettings (const QAudioEncoderSettings &audioSettings)
 
void setContainerFormat (const QString &format)
 
void setEncodingSettings (const QAudioEncoderSettings &audioSettings, const QVideoEncoderSettings &videoSettings=QVideoEncoderSettings (), const QString &mimeType=QString ())
 
void setMetaData (const QString &key, const QVariant &value)
 
bool setOutputLocation (const QUrl &location)
 
void setVideoSettings (const QVideoEncoderSettings &videoSettings)
 
State state () const
 
Status status () const
 
QStringList supportedAudioCodecs () const
 
QList< int > supportedAudioSampleRates (const QAudioEncoderSettings &settings=QAudioEncoderSettings (), bool *continuous=nullptr) const
 
QStringList supportedContainers () const
 
QList< qrealsupportedFrameRates (const QVideoEncoderSettings &settings=QVideoEncoderSettings (), bool *continuous=nullptr) const
 
QList< QSizesupportedResolutions (const QVideoEncoderSettings &settings=QVideoEncoderSettings (), bool *continuous=nullptr) const
 
QStringList supportedVideoCodecs () const
 
QString videoCodecDescription (const QString &codecName) const
 
QVideoEncoderSettings videoSettings () const
 
qreal volume () const
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 
- Public Methods inherited from QMediaBindableInterface
virtual ~QMediaBindableInterface ()
 

Protected Methods

bool setMediaObject (QMediaObject *object) override
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 

Properties

 actualLocation
 Actual location of the last media content. More...
 
 duration
 Recorded media duration in milliseconds. More...
 
 metaDataAvailable
 Whether access to a media object's metadata is available. More...
 
 metaDataWritable
 Whether a media object's metadata is writable. More...
 
 muted
 Whether a recording audio stream is muted. More...
 
 outputLocation
 the destination location of media content. More...
 
 state
 Current state of the media recorder. More...
 
 status
 Current status of the media recorder. More...
 
 volume
 Linear audio gain of media recorder. More...
 
- Properties inherited from QObject
 objectName
 

Additional Inherited Members

- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 

Detailed Description

The QMediaRecorder class is a high level media recording class. It is 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);
audioSettings.setCodec("audio/amr");
audioSettings.setQuality(QMultimedia::HighQuality);
recorder->record();
See also
QAudioRecorder

Member Enumeration Documentation

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.
Constant Value Description
QMediaRecorder::StoppedState 0 Recorder is not active.
QMediaRecorder::RecordingState 1 Recording is requested.
QMediaRecorder::PausedState 2 Recorder is paused.
Constant Value Description
QMediaRecorder::UnavailableStatus 0 The recorder is not available or not supported by connected media object.
QMediaRecorder::UnloadedStatus 1 The recorder is available 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.

Constructor & Destructor Documentation

QMediaRecorder::QMediaRecorder ( QMediaObject mediaObject,
QObject parent = nullptr 
)
explicit

Constructs a media recorder which records the media produced by mediaObject. The parent is passed to QMediaObject.

QMediaRecorder::~QMediaRecorder ( )

Destroys a media recorder object.

Method Documentation

QUrl QMediaRecorder::actualLocation ( ) const

Returns the current value of the actualLocation property.

void QMediaRecorder::actualLocationChanged ( const QUrl location)
signal

Signals the actual location of the recorded media has changed. This signal is usually emitted when recording starts.

QString QMediaRecorder::audioCodecDescription ( const QString codecName) const

Returns a description of an audio codecName.

QAudioEncoderSettings QMediaRecorder::audioSettings ( ) const

Returns the audio encoder settings being used.

See also
setEncodingSettings()
QMultimedia::AvailabilityStatus QMediaRecorder::availability ( ) const

Returns the availability of this functionality.

See also
availabilityChanged()
void QMediaRecorder::availabilityChanged ( bool  available)
signal

Signals that the media recorder is now available (if available is true), or not.

void QMediaRecorder::availabilityChanged ( QMultimedia::AvailabilityStatus  availability)
signal

Signals that the service availability has changed to availability.

QStringList QMediaRecorder::availableMetaData ( ) const

Returns a list of keys there is metadata available for.

QString QMediaRecorder::containerDescription ( const QString format) const

Returns a description of a container format.

QString QMediaRecorder::containerFormat ( ) const

Returns the selected container format.

qint64 QMediaRecorder::duration ( ) const

Returns the current value of the duration property.

void QMediaRecorder::durationChanged ( qint64  duration)
signal

Signals that the duration of the recorded media has changed.

QMediaRecorder::Error QMediaRecorder::error ( ) const

Returns the current error state.

See also
errorString()
void QMediaRecorder::error ( QMediaRecorder::Error  error)
signal

Signals that an error has occurred.

QString QMediaRecorder::errorString ( ) const

Returns a string describing the current error state.

See also
error()
bool QMediaRecorder::isAvailable ( ) const

Returns true if media recorder service ready to use.

See also
availabilityChanged()
bool QMediaRecorder::isMetaDataAvailable ( ) const

Returns true if the media object's metadata is available. The property is called metaDataAvailable.

bool QMediaRecorder::isMetaDataWritable ( ) const

Returns true if the media object metadata is writeable. The property is called metaDataWritable.

bool QMediaRecorder::isMuted ( ) const

Returns true if the recording audio stream is muted. The property is called muted.

QMediaObject * QMediaRecorder::mediaObject ( ) const
overridevirtual

Returns the QMediaObject instance this QMediaRecorder is bound too, otherwise nullptr.

Implements QMediaBindableInterface::mediaObject()

QVariant QMediaRecorder::metaData ( const QString key) const

Returns the value associated with a metadata key.

void QMediaRecorder::metaDataAvailableChanged ( bool  available)
signal

Signals that the available state of a media object's metadata has changed.

void QMediaRecorder::metaDataChanged ( )
signal

Signals that a media object's metadata has changed.

If multiple metadata elements are changed, metaDataChanged(const QString &key, const QVariant &value) signal is emitted for each of them with metaDataChanged() changed emitted once.

void QMediaRecorder::metaDataChanged ( const QString key,
const QVariant value 
)
signal

Signal the changes of one metadata element value with the given key.

void QMediaRecorder::metaDataWritableChanged ( bool  writable)
signal

Signals that the writable state of a media object's metadata has changed.

void QMediaRecorder::mutedChanged ( bool  muted)
signal

Signals that the muted state has changed. If true the recording is being muted.

QUrl QMediaRecorder::outputLocation ( ) const

Returns the current value of the outputLocation property.

void QMediaRecorder::pause ( )
slot

Pause recording.

The recorder state is changed to QMediaRecorder::PausedState. Depending on platform recording pause may be not supported, in this case the recorder state stays unchanged.

void QMediaRecorder::record ( )
slot

Start recording.

While the recorder state is changed immediately to QMediaRecorder::RecordingState, recording may start asynchronously, with statusChanged(QMediaRecorder::RecordingStatus) signal emitted when recording starts. If recording fails error() signal is emitted with recorder state being reset back to QMediaRecorder::StoppedState.

See also
QMediaRecorder::State
void QMediaRecorder::setAudioSettings ( const QAudioEncoderSettings audioSettings)

Sets the audio encoder to the given audioSettings.

If some parameters are not specified, or null settings are passed, the encoder will choose default encoding parameters, depending on media source properties. It is only possible to change settings when the encoder is in the QMediaEncoder::StoppedState state.

See also
audioSettings(), videoSettings(), containerFormat()
void QMediaRecorder::setContainerFormat ( const QString format)

Sets the media container to the given format.

If the container format is not specified, the encoder will choose format, depending on media source properties and encoding settings selected. It is only possible to change settings when the encoder is in the QMediaEncoder::StoppedState state.

See also
audioSettings(), videoSettings(), containerFormat()
void QMediaRecorder::setEncodingSettings ( const QAudioEncoderSettings audioSettings,
const QVideoEncoderSettings videoSettings = QVideoEncoderSettings(),
const QString mimeType = QString() 
)

Sets the audioSettings, videoSettings, and mimeType format.

If some parameters are not specified, or null settings are passed, the encoder will choose default encoding parameters, depending on media source properties. It is only possible to change settings when the encoder is in the QMediaEncoder::StoppedState state.

See also
audioSettings(), videoSettings(), containerFormat()
bool QMediaRecorder::setMediaObject ( QMediaObject object)
overrideprotectedvirtual

Attaches to the media object. Returns true if attached successfully, otherwise returns false.

Implements QMediaBindableInterface::setMediaObject()

void QMediaRecorder::setMetaData ( const QString key,
const QVariant value 
)

Sets a value for a metadata key.

To ensure that metadata is set correctly, it should be set before starting the recording. Once the recording is stopped, any metadata set will be attached to the next recording.

void QMediaRecorder::setMuted ( bool  muted)
slot

Sets the current value of the muted property to muted.

bool QMediaRecorder::setOutputLocation ( const QUrl location)

Sets the current value of the outputLocation property to location.

void QMediaRecorder::setVideoSettings ( const QVideoEncoderSettings videoSettings)

Sets the video encoder videoSettings.

If some parameters are not specified, or null settings are passed, the encoder will choose default encoding parameters, depending on media source properties. It is only possible to change settings when the encoder is in the QMediaEncoder::StoppedState state.

See also
audioSettings(), videoSettings(), containerFormat()
void QMediaRecorder::setVolume ( qreal  volume)
slot

Sets the current value of the volume property to volume.

QMediaRecorder::State QMediaRecorder::state ( ) const

Returns the current media recorder state.

See also
QMediaRecorder::State
void QMediaRecorder::stateChanged ( QMediaRecorder::State  state)
signal

Signals the media recorder state has changed.

QMediaRecorder::Status QMediaRecorder::status ( ) const

Returns the current media recorder status.

See also
QMediaRecorder::Status
void QMediaRecorder::statusChanged ( QMediaRecorder::Status  status)
signal

Signals that the media recorder's status has changed.

void QMediaRecorder::stop ( )
slot

Stop recording. The recorder state property is changed to the enum value of QMediaRecorder::StoppedState.

See also
QMediaRecorder::State
QStringList QMediaRecorder::supportedAudioCodecs ( ) const

Returns a list of supported audio codecs.

QList< int > QMediaRecorder::supportedAudioSampleRates ( const QAudioEncoderSettings settings = QAudioEncoderSettings(),
bool *  continuous = nullptr 
) const

Returns a list of supported audio sample rates.

If the settings parameter is not null, the returned list is reduced to sample rates supported with partial settings applied. This can be used to query the list of sample rates supported by specific audio codec. If the encoder supports arbitrary sample rates within the supported rates range, continuous is set to true, otherwise it is set to false.

QStringList QMediaRecorder::supportedContainers ( ) const

Returns a list of supported container formats.

QList< qreal > QMediaRecorder::supportedFrameRates ( const QVideoEncoderSettings settings = QVideoEncoderSettings(),
bool *  continuous = nullptr 
) const

Returns a list of frame rates video can be encoded at.

If the settings parameter is not null, the returned list is reduced to frame rates supported with partial settings like video codec or resolution applied. If the encoder supports arbitrary frame rates within the supported range, continuous is set to true, otherwise it is set to false.

See also
QVideoEncoderSettings::frameRate()
QList< QSize > QMediaRecorder::supportedResolutions ( const QVideoEncoderSettings settings = QVideoEncoderSettings(),
bool *  continuous = nullptr 
) const

Returns a list of resolutions video can be encoded at.

If the settings parameter is not null, the returned list is reduced to resolution supported with partial settings like video codec or framerate applied. If the encoder supports arbitrary resolutions within the supported range, continuous is set to true, otherwise it is set to false.

See also
QVideoEncoderSettings::resolution()
QStringList QMediaRecorder::supportedVideoCodecs ( ) const

Returns a list of supported video codecs.

QString QMediaRecorder::videoCodecDescription ( const QString codecName) const

Returns a description of a video codecName.

See also
setEncodingSettings()
QVideoEncoderSettings QMediaRecorder::videoSettings ( ) const

Returns the video encoder settings being used.

See also
setEncodingSettings()
qreal QMediaRecorder::volume ( ) const

Returns the current value of the volume property.

void QMediaRecorder::volumeChanged ( qreal  volume)
signal

Signals that the media recorder volume has changed.

Property Documentation

QMediaRecorder::actualLocation

The actual location is usually available after recording starts, and reset when new location is set or new recording starts.

PropertiesClass Methods
read actualLocation
notify actualLocationChanged
QMediaRecorder::duration

The property stores the recorded media duration in milliseconds.

PropertiesClass Methods
read duration
notify durationChanged
QMediaRecorder::metaDataAvailable

If this is true there is metadata available, otherwise there is no metadata available.

PropertiesClass Methods
read isMetaDataAvailable
notify metaDataAvailableChanged
QMediaRecorder::metaDataWritable

If this is true the metadata is writable, otherwise the metadata is read only.

PropertiesClass Methods
read isMetaDataWritable
notify metaDataWritableChanged
QMediaRecorder::muted

Stores whether a recording audio stream is muted.

PropertiesClass Methods
read isMuted
write setMuted
notify mutedChanged
QMediaRecorder::outputLocation

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.

PropertiesClass Methods
read outputLocation
write setOutputLocation
QMediaRecorder::state

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.

PropertiesClass Methods
read state
notify stateChanged
QMediaRecorder::status

The status is changed asynchronously and represents the actual status of media recorder.

PropertiesClass Methods
read status
notify statusChanged
QMediaRecorder::volume

This property stores the linear audio gain of the media recorder.

PropertiesClass Methods
read volume
write setVolume
notify volumeChanged