QAudioDecoder#
The QAudioDecoder
class implements decoding audio. More…
Synopsis#
Properties#
bufferAvailable
- Whether there is a decoded audio buffer availableisDecoding
- True if the decoder is currently running and decoding audio datasource
- The active filename being decoded by the decoder object
Functions#
def
audioFormat
()def
bufferAvailable
()def
duration
()def
error
()def
errorString
()def
isDecoding
()def
isSupported
()def
position
()def
read
()def
setAudioFormat
(format)def
setSource
(fileName)def
setSourceDevice
(device)def
source
()def
sourceDevice
()
Slots#
Signals#
def
bufferAvailableChanged
(arg__1)def
bufferReady
()def
durationChanged
(duration)def
error
(error)def
finished
()def
formatChanged
(format)def
isDecodingChanged
(arg__1)def
positionChanged
(position)def
sourceChanged
()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description#
The QAudioDecoder
class is a high level class for decoding 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.
See also
- class PySide6.QtMultimedia.QAudioDecoder([parent=None])#
- Parameters:
parent –
PySide6.QtCore.QObject
Construct an QAudioDecoder
instance with parent
.
Note
Properties can be used directly when from __feature__ import true_property
is used or via accessor functions otherwise.
- property PᅟySide6.QtMultimedia.QAudioDecoder.bufferAvailable: bool#
This property holds whether there is a decoded audio buffer available.
- Access functions:
Signal
bufferAvailableChanged
(arg__1)
- property PᅟySide6.QtMultimedia.QAudioDecoder.error: str#
Returns a human readable description of the current error, or an empty string is there is no error.
- Access functions:
errorString
()
- property PᅟySide6.QtMultimedia.QAudioDecoder.isDecoding: bool#
This property holds true
if the decoder is currently running and decoding audio data..
- Access functions:
isDecoding
()Signal
isDecodingChanged
(arg__1)
- property PᅟySide6.QtMultimedia.QAudioDecoder.source: PySide6.QtCore.QUrl#
This property holds the active filename being decoded by the decoder object..
- Access functions:
source
()setSource
(fileName)Signal
sourceChanged
()
- PySide6.QtMultimedia.QAudioDecoder.Error#
Defines a media player error condition.
Constant
Description
QAudioDecoder.NoError
No error has occurred.
QAudioDecoder.ResourceError
A media resource couldn’t be resolved.
QAudioDecoder.FormatError
The format of a media resource isn’t supported.
QAudioDecoder.AccessDeniedError
There are not the appropriate permissions to play a media resource.
QAudioDecoder.NotSupportedError
QAudioDecoder
is not supported on this platform
- PySide6.QtMultimedia.QAudioDecoder.audioFormat()#
- Return type:
Returns the audio format the decoder is set to.
Note
This may be different than the format of the decoded samples, if the audio format was set to an invalid one.
See also
- PySide6.QtMultimedia.QAudioDecoder.bufferAvailable()#
- Return type:
bool
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 of property bufferAvailable
.
- PySide6.QtMultimedia.QAudioDecoder.bufferAvailableChanged(arg__1)#
- Parameters:
arg__1 – bool
Signals the availability (if available
is true) of a new buffer.
If available
is false, there are no buffers available.
See also
Notification signal of property bufferAvailable
.
- PySide6.QtMultimedia.QAudioDecoder.bufferReady()#
Signals that a new decoded audio buffer is available to be read.
See also
- PySide6.QtMultimedia.QAudioDecoder.duration()#
- Return type:
int
Returns total duration (in milliseconds) of the audio stream or -1 if not available.
- PySide6.QtMultimedia.QAudioDecoder.durationChanged(duration)#
- Parameters:
duration – int
Signals that the estimated duration
of the decoded data has changed.
See also
Returns the current error state of the QAudioDecoder
.
- PySide6.QtMultimedia.QAudioDecoder.error(error)
- Parameters:
error –
Error
Signals that an error
condition has occurred.
See also
- PySide6.QtMultimedia.QAudioDecoder.errorString()#
- Return type:
str
Getter of property error
.
- PySide6.QtMultimedia.QAudioDecoder.finished()#
Signals that the decoding has finished successfully. If decoding fails, error signal is emitted instead.
- PySide6.QtMultimedia.QAudioDecoder.formatChanged(format)#
- Parameters:
format –
PySide6.QtMultimedia.QAudioFormat
Signals that the current audio format of the decoder has changed to format
.
See also
- PySide6.QtMultimedia.QAudioDecoder.isDecoding()#
- Return type:
bool
Getter of property isDecoding
.
- PySide6.QtMultimedia.QAudioDecoder.isDecodingChanged(arg__1)#
- Parameters:
arg__1 – bool
Notification signal of property isDecoding
.
- PySide6.QtMultimedia.QAudioDecoder.isSupported()#
- Return type:
bool
Returns true is audio decoding is supported on this platform.
- PySide6.QtMultimedia.QAudioDecoder.position()#
- Return type:
int
Returns position (in milliseconds) of the last buffer read from the decoder or -1 if no buffers have been read.
- PySide6.QtMultimedia.QAudioDecoder.positionChanged(position)#
- Parameters:
position – int
Signals that the current position
of the decoder has changed.
See also
- PySide6.QtMultimedia.QAudioDecoder.read()#
- Return type:
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.
- PySide6.QtMultimedia.QAudioDecoder.setAudioFormat(format)#
- Parameters:
format –
PySide6.QtMultimedia.QAudioFormat
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
.
- PySide6.QtMultimedia.QAudioDecoder.setSource(fileName)#
- Parameters:
fileName –
PySide6.QtCore.QUrl
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.
See also
Setter of property source
.
- PySide6.QtMultimedia.QAudioDecoder.setSourceDevice(device)#
- Parameters:
device –
PySide6.QtCore.QIODevice
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
- PySide6.QtMultimedia.QAudioDecoder.source()#
- Return type:
Returns the current file name to decode. If setSourceDevice
was called, this will be empty.
See also
Getter of property source
.
- PySide6.QtMultimedia.QAudioDecoder.sourceChanged()#
Signals that the current source of the decoder has changed.
See also
Notification signal of property source
.
- PySide6.QtMultimedia.QAudioDecoder.sourceDevice()#
- Return type:
Returns the current source QIODevice
, if one was set. If setSource()
was called, this will be a nullptr.
See also
- PySide6.QtMultimedia.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
- PySide6.QtMultimedia.QAudioDecoder.stop()#
Stop decoding audio. Calling start()
again will resume decoding from the beginning.