CopperSpice API  1.7.2
QAudioRecorder Class Reference

The QAudioRecorder class is used for the recording of audio. More...

Inheritance diagram for QAudioRecorder:
QMediaRecorder QObject QMediaBindableInterface

Public Signals

void audioInputChanged (const QString &name)
 
void availableAudioInputsChanged ()
 
- Public Signals inherited from QMediaRecorder
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 setAudioInput (const QString &name)
 
- Public Slots inherited from QMediaRecorder
void pause ()
 
void record ()
 
void setMuted (bool muted)
 
void setVolume (qreal volume)
 
void stop ()
 
- Public Slots inherited from QObject
void deleteLater ()
 

Public Methods

 QAudioRecorder (QObject *parent=nullptr)
 
 ~QAudioRecorder ()
 
QString audioInput () const
 
QString audioInputDescription (const QString &name) const
 
QStringList audioInputs () const
 
QString defaultAudioInput () const
 
- Public Methods inherited from QMediaRecorder
 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 &container)
 
void setEncodingSettings (const QAudioEncoderSettings &audioSettings, const QVideoEncoderSettings &videoSettings=QVideoEncoderSettings (), const QString &containerMimeType=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 &objName=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 ()
 

Properties

 audioInput
 Active audio input name. More...
 
- Properties inherited from QMediaRecorder
 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

- Public Types inherited from QMediaRecorder
enum  Error
 
enum  State
 
enum  Status
 
- 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)
 
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 >())
 
- Protected Methods inherited from QMediaRecorder
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)
 

Detailed Description

The QAudioRecorder class is a high level media recording class and contains the same functionality as QMediaRecorder.

audioRecorder = new QAudioRecorder;
audioSettings.setCodec("audio/amr");
audioSettings.setQuality(QMultimedia::HighQuality);
audioRecorder->setEncodingSettings(audioSettings);
audioRecorder->setOutputLocation(QUrl::fromLocalFile("test.amr"));
audioRecorder->record();

In addition QAudioRecorder provides functionality for selecting the audio input.

QStringList inputs = audioRecorder->audioInputs();
QString selectedInput = audioRecorder->defaultAudioInput();
for (QString input : inputs) {
QString description = audioRecorder->audioInputDescription(input);
// show descriptions to user and allow selection
selectedInput = input;
}
audioRecorder->setAudioInput(selectedInput);
See also
QMediaRecorder, QAudioInputSelectorControl

Constructor & Destructor Documentation

QAudioRecorder::QAudioRecorder ( QObject parent = nullptr)
explicit

Constructs an audio recorder. The parent is passed to QMediaObject.

QAudioRecorder::~QAudioRecorder ( )

Destroys an audio recorder object.

Method Documentation

QString QAudioRecorder::audioInput ( ) const

Returns the active audio input name.

void QAudioRecorder::audioInputChanged ( const QString name)
signal

Signal emitted when active audio input changes to name.

QString QAudioRecorder::audioInputDescription ( const QString name) const

Returns the readable translated description of the audio input device with name.

QStringList QAudioRecorder::audioInputs ( ) const

Returns a list of available audio inputs

void QAudioRecorder::availableAudioInputsChanged ( )
signal

Signal is emitted when the available audio inputs change.

QString QAudioRecorder::defaultAudioInput ( ) const

Returns the default audio input name.

void QAudioRecorder::setAudioInput ( const QString name)
slot

Set the active audio input to name.

Property Documentation

QAudioRecorder::audioInput

This property stores the aactive audio input name.

PropertiesClass Methods
read audioInput
write setAudioInput
notify audioInputChanged