CopperSpice API
1.9.2
|
The QAudioDecoder class allows decoding audio. More...
Public Types | |
enum | Error |
enum | State |
Public Signals | |
void | bufferAvailableChanged (bool available) |
void | bufferReady () |
void | durationChanged (qint64 duration) |
void | error (QAudioDecoder::Error error) |
void | finished () |
void | formatChanged (const QAudioFormat &format) |
void | positionChanged (qint64 position) |
void | sourceChanged () |
void | stateChanged (QAudioDecoder::State state) |
Public Signals inherited from QMediaObject | |
void | availabilityChanged (bool available) |
void | availabilityChanged (QMultimedia::AvailabilityStatus availability) |
void | metaDataAvailableChanged (bool available) |
void | metaDataChanged () |
void | metaDataChanged (const QString &key, const QVariant &value) |
void | notifyIntervalChanged (int milliSeconds) |
Public Signals inherited from QObject | |
void | destroyed (QObject *obj=nullptr) |
void | objectNameChanged (const QString &objectName) |
Public Slots | |
void | start () |
void | stop () |
Public Slots inherited from QObject | |
void | deleteLater () |
Public Methods | |
QAudioDecoder (QObject *parent=nullptr) | |
~QAudioDecoder () | |
QAudioFormat | audioFormat () const |
bool | bind (QObject *object) override |
bool | bufferAvailable () const |
qint64 | duration () const |
Error | error () const |
QString | errorString () const |
qint64 | position () const |
QAudioBuffer | read () const |
void | setAudioFormat (const QAudioFormat &format) |
void | setSourceDevice (QIODevice *device) |
void | setSourceFilename (const QString &fileName) |
QIODevice * | sourceDevice () const |
QString | sourceFilename () const |
State | state () const |
void | unbind (QObject *object) override |
Public Methods inherited from QMediaObject | |
~QMediaObject () | |
virtual QMultimedia::AvailabilityStatus | availability () const |
QStringList | availableMetaData () const |
virtual bool | isAvailable () const |
bool | isMetaDataAvailable () const |
QVariant | metaData (const QString &key) const |
int | notifyInterval () const |
virtual QMediaService * | service () const |
void | setNotifyInterval (int milliSeconds) |
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< QString > | dynamicPropertyNames () const |
virtual bool | event (QEvent *event) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
template<typename T > | |
T | findChild (const QString &childName=QString ()) const |
template<class T > | |
QList< T > | findChildren (const QRegularExpression ®Exp, 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 QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const |
QObject * | parent () const |
template<class T = QVariant> | |
T | 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) |
QThread * | thread () const |
Static Public Methods | |
static QMultimedia::SupportEstimate | hasSupport (const QString &mimeType, const QStringList &codecs=QStringList ()) |
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 QMetaObject & | staticMetaObject () |
static QString | tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >()) |
Properties | |
bufferAvailable | |
Whether there is a decoded audio buffer available. More... | |
error | |
String describing the last error condition. More... | |
sourceFilename | |
Active filename being decoded by the decoder object. More... | |
state | |
Audio decoder's playback state. More... | |
Properties inherited from QMediaObject | |
notifyInterval | |
Properties inherited from QObject | |
objectName | |
Additional Inherited Members | |
Protected Methods inherited from QMediaObject | |
QMediaObject (QObject *parent, QMediaService *service) | |
template<typename T > | |
void | addPropertyWatch (const QString &name) |
void | removePropertyWatch (const QString &name) |
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) |
Related Functions inherited from QObject | |
T | qobject_cast (QObject *object) |
QObjectList | |
The QAudioDecoder class is a high level class for decoding local audio media files. It is similar to the QMediaPlayer class except that audio is provided back through this API rather than routed directly to audio hardware, and playlists and network and streaming based media is not supported.
enum QAudioDecoder::Error |
Defines a media player error condition.
Constant | Value | Description |
---|---|---|
QAudioDecoder::NoError | 0 | No error has occurred |
QAudioDecoder::ResourceError | 1 | Media resource could not be resolved |
QAudioDecoder::FormatError | 2 | Format of a media resource is not supported |
QAudioDecoder::AccessDeniedError | 3 | There are not the appropriate permissions to play a media resource |
QAudioDecoder::ServiceMissingError | 4 | Valid playback service was not found, playback cannot proceed |
enum QAudioDecoder::State |
Defines the current state of a media player.
Constant | Value | Description |
---|---|---|
QAudioDecoder::StoppedState | 0 | Decoder is not decoding, will start at the beginning of the media |
QAudioDecoder::DecodingState | 1 | Audio player is currently decoding media |
|
explicit |
Construct an QAudioDecoder instance parented to parent.
QAudioDecoder::~QAudioDecoder | ( | ) |
Destroys the audio decoder object.
QAudioFormat QAudioDecoder::audioFormat | ( | ) | const |
Returns the current audio format of the decoded stream. Any buffers returned should have this format.
|
overridevirtual |
Bind object to this QMediaObject instance. This method establishes a relationship between this media object and a helper object. The nature of the relationship depends on both parties. This methods returns true if the helper was successfully bound, false otherwise.
Most subclasses of QMediaObject provide more convenient functions that wrap this functionality so this function rarely needs to be called directly.
The object passed must implement the QMediaBindableInterface interface.
Reimplemented from QMediaObject::bind()
bool QAudioDecoder::bufferAvailable | ( | ) | const |
Returns true if a buffer is available to be read, and false otherwise. If there is no buffer available, calling read() will return an invalid buffer.
|
signal |
Signals the availability (if available is true) of a new buffer. If available is false, there are no buffers available.
|
signal |
Signals a new decoded audio buffer is available to be read.
qint64 QAudioDecoder::duration | ( | ) | const |
Returns total duration (in milliseconds) of the audio stream or -1 if not available.
|
signal |
Signals the estimated duration of the decoded data has changed.
QAudioDecoder::Error QAudioDecoder::error | ( | ) | const |
Returns the current error state.
|
signal |
Signals an error condition has occurred.
QString QAudioDecoder::errorString | ( | ) | const |
Return the value of the error property.
|
signal |
|
signal |
Signals the current audio format of the decoder has changed to format.
|
static |
Returns the level of support an audio decoder has for a mimeType and a set of codecs.
qint64 QAudioDecoder::position | ( | ) | const |
Returns position (in milliseconds) of the last buffer read from the decoder or -1 if no buffers have been read.
|
signal |
Signals the current position of the decoder has changed.
QAudioBuffer QAudioDecoder::read | ( | ) | const |
Read a buffer from the decoder, if one is available. Returns an invalid buffer if there are no decoded buffers currently available, or on failure. In both cases this function will not block.
You should either respond to the bufferReady() signal or check the bufferAvailable() methods before calling read() to make sure you get useful data.
void QAudioDecoder::setAudioFormat | ( | const QAudioFormat & | format | ) |
Set the desired audio format for decoded samples to format. This property can only be set while the decoder is stopped. Setting this property at other times will be ignored.
If the decoder does not support this format, error() will be set to FormatError. If you do not specify a format, the format of the decoded audio itself will be used. Otherwise, some format conversion will be applied. To reset the decoded format to that of the original audio file, you can specify an invalid format.
void QAudioDecoder::setSourceDevice | ( | QIODevice * | device | ) |
void QAudioDecoder::setSourceFilename | ( | const QString & | fileName | ) |
Sets the current audio file name to fileName. When this property is set any current decoding is stopped, and any audio buffers are discarded.
You can only specify either a source filename or a source QIODevice. Setting one will unset the other.
|
signal |
Signals the current source of the decoder has changed.
QIODevice * QAudioDecoder::sourceDevice | ( | ) | const |
Returns the current source QIODevice, if one was set. If setSourceFilename() was called, this will be 0.
QString QAudioDecoder::sourceFilename | ( | ) | const |
Returns the current file name to decode. If setSourceDevice() was called there is no file name so the return value will be an empty string.
|
slot |
Starts decoding the audio resource.
As data gets decoded, the bufferReady() signal will be emitted when enough data has been decoded. Calling read() will then return an audio buffer without blocking. If you call read() before a buffer is ready, an invalid buffer will be returned, again without blocking.
State QAudioDecoder::state | ( | ) | const |
Returns the audio decoder's playback state.
|
signal |
Signal the state of the decoder object has changed.
|
slot |
Stop decoding audio. Calling start() again will resume decoding from the beginning.
|
overridevirtual |
Detach object from the QMediaObject instance. Unbind the helper object from this media object. A warning will be generated if the object was not previously bound to this object.
Reimplemented from QMediaObject::unbind()
|
This property stores whether there is a decoded audio buffer available.
Properties | Class Methods |
---|---|
read | bufferAvailable |
notify | bufferAvailableChanged |
|
This property stores a string describing the last error condition.
Properties | Class Methods |
---|---|
read | errorString |
|
This property stores the active filename being decoded by the decoder object.
Properties | Class Methods |
---|---|
read | sourceFilename |
write | setSourceFilename |
notify | sourceChanged |