IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

QAudioDecoder Class

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QAudioDecoder Class

  • Header: QAudioDecoder

  • qmake: QT += multimedia

  • Inherits: QMediaObject

  • Group: QAudioDecoder is part of multimedia, multimedia_audio

This class is under development and is subject to change.

Detailed Description

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.

See Also

See also QAudioBuffer

Member Type Documentation

 

enum QAudioDecoder::Error

Defines a media player error condition.

Constant

Value

Description

QAudioDecoder::NoError

0

No error has occurred.

QAudioDecoder::ResourceError

1

A media resource couldn't be resolved.

QAudioDecoder::FormatError

2

The format of a media resource isn't supported.

QAudioDecoder::AccessDeniedError

3

There are not the appropriate permissions to play a media resource.

QAudioDecoder::ServiceMissingError

4

A 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

The decoder is not decoding. Decoding will start at the start of the media.

QAudioDecoder::DecodingState

1

The audio player is currently decoding media.

Property Documentation

 

[read-only] bufferAvailable : const bool

This property holds whether there is a decoded audio buffer available

Access functions:

Notifier signal:

[read-only] error : const QString

This property holds a string describing the last error condition.

Access functions:

  • errorString() const

See Also

See also error()

sourceFilename : QString

This property holds the active filename being decoded by the decoder object.

Access functions:

Notifier signal:

[read-only] state : const State

This property holds the audio decoder's playback state.

By default this property is QAudioDecoder::Stopped

Access functions:

  • state() const

Notifier signal:

See Also

See also start(), stop()

Member Function Documentation

 

[explicit] QAudioDecoder::QAudioDecoder(QObject *parent = nullptr)

Construct an QAudioDecoder instance parented to parent.

[virtual] 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.

See Also

bool QAudioDecoder::bufferAvailable() const

Returns true if a buffer is available to be read, and false otherwise. If there is no buffer available, calling the read() function will return an invalid buffer.

Getter function for property bufferAvailable.

void QAudioDecoder::bufferAvailableChanged(bool available)

Signals the availability (if available is true) of a new buffer.

If available is false, there are no buffers available.

Notifier signal for property bufferAvailable.

See Also

void QAudioDecoder::bufferReady()

Signals that a new decoded audio buffer is available to be read.

See Also

See also read(), bufferAvailable()

qint64 QAudioDecoder::duration() const

Returns total duration (in milliseconds) of the audio stream or -1 if not available.

void QAudioDecoder::durationChanged(qint64 duration)

Signals that the estimated duration of the decoded data has changed.

See Also

See also positionChanged()

QAudioDecoder::Error QAudioDecoder::error() const

Returns the current error state.

void QAudioDecoder::error(QAudioDecoder::Error error)

Signals that an error condition has occurred.

See Also

See also errorString()

void QAudioDecoder::finished()

Signals that the decoding has finished successfully. If decoding fails, error signal is emitted instead.

See Also

See also start(), stop(), error()

void QAudioDecoder::formatChanged(const QAudioFormat &format)

Signals that the current audio format of the decoder has changed to format.

See Also

See also audioFormat(), setAudioFormat()

[static] QMultimedia::SupportEstimate QAudioDecoder::hasSupport(const QString &mimeType, const QStringList &codecs = QStringList())

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.

void QAudioDecoder::positionChanged(qint64 position)

Signals that the current position of the decoder has changed.

See Also

See also durationChanged()

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() function 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.

If you wish to reset the decoded format to that of the original audio file, you can specify an invalid format.

See Also

See also audioFormat()

void QAudioDecoder::setSourceDevice(QIODevice *device)

Sets the current audio QIODevice to device.

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.

See Also

See also sourceDevice()

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.

Setter function for property sourceFilename.

See Also

See also sourceFilename()

void QAudioDecoder::sourceChanged()

Signals that the current source of the decoder has changed.

Notifier signal for property sourceFilename.

See Also

QIODevice *QAudioDecoder::sourceDevice() const

Returns the current source QIODevice, if one was set. If setSourceFilename() was called, this will be 0.

See Also

See also setSourceDevice()

QString QAudioDecoder::sourceFilename() const

Returns the current file name to decode. If setSourceDevice was called, this will be empty.

Getter function for property sourceFilename.

See Also

See also setSourceFilename()

void QAudioDecoder::start()

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.

See Also

See also read()

void QAudioDecoder::stateChanged(QAudioDecoder::State state)

Signal the state of the decoder object has changed.

Notifier signal for property state.

void QAudioDecoder::stop()

Stop decoding audio. Calling start() again will resume decoding from the beginning.

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+