QAudioDecoder¶
The
QAudioDecoder
class allows decoding audio. More…
Synopsis¶
Functions¶
def
audioFormat
()def
bufferAvailable
()def
duration
()def
error
()def
errorString
()def
position
()def
read
()def
setAudioFormat
(format)def
setSourceDevice
(device)def
setSourceFilename
(fileName)def
sourceDevice
()def
sourceFilename
()def
state
()
Slots¶
Signals¶
def
bufferAvailableChanged
(arg__1)def
bufferReady
()def
durationChanged
(duration)def
error
(error)def
finished
()def
formatChanged
(format)def
positionChanged
(position)def
sourceChanged
()def
stateChanged
(newState)
Static functions¶
def
hasSupport
(mimeType[, codecs=list()])
Detailed Description¶
The
QAudioDecoder
class is a high level class for decoding local audio media files. It is similar to theQMediaPlayer
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
- class PySide2.QtMultimedia.QAudioDecoder([parent=None])¶
- param parent:
Construct an
QAudioDecoder
instance parented toparent
.
- PySide2.QtMultimedia.QAudioDecoder.State¶
Defines the current state of a media player.
Constant
Description
QAudioDecoder.StoppedState
The decoder is not decoding. Decoding will start at the start of the media.
QAudioDecoder.DecodingState
The audio player is currently decoding media.
- PySide2.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.ServiceMissingError
A valid playback service was not found, playback cannot proceed.
- PySide2.QtMultimedia.QAudioDecoder.audioFormat()¶
- Return type:
Returns the current audio format of the decoded stream.
Any buffers returned should have this format.
See also
- PySide2.QtMultimedia.QAudioDecoder.bufferAvailable()¶
- Return type:
bool
This property holds whether there is a decoded audio buffer available.
- PySide2.QtMultimedia.QAudioDecoder.bufferAvailableChanged(arg__1)¶
- Parameters:
arg__1 – bool
- PySide2.QtMultimedia.QAudioDecoder.bufferReady()¶
- PySide2.QtMultimedia.QAudioDecoder.duration()¶
- Return type:
int
Returns total duration (in milliseconds) of the audio stream or -1 if not available.
- PySide2.QtMultimedia.QAudioDecoder.durationChanged(duration)¶
- Parameters:
duration – int
- PySide2.QtMultimedia.QAudioDecoder.error(error)
- Parameters:
error –
Error
- PySide2.QtMultimedia.QAudioDecoder.errorString()¶
- Return type:
str
This property holds a string describing the last error condition..
See also
- PySide2.QtMultimedia.QAudioDecoder.finished()¶
- PySide2.QtMultimedia.QAudioDecoder.formatChanged(format)¶
- Parameters:
format –
PySide2.QtMultimedia.QAudioFormat
- static PySide2.QtMultimedia.QAudioDecoder.hasSupport(mimeType[, codecs=list()])¶
- Parameters:
mimeType – str
codecs – list of strings
- Return type:
Returns the level of support an audio decoder has for a
mimeType
and a set ofcodecs
.
- PySide2.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.
- PySide2.QtMultimedia.QAudioDecoder.positionChanged(position)¶
- Parameters:
position – int
- PySide2.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 thebufferAvailable()
function before calling to make sure you get useful data.
- PySide2.QtMultimedia.QAudioDecoder.setAudioFormat(format)¶
- Parameters:
format –
PySide2.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 toFormatError
.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
- PySide2.QtMultimedia.QAudioDecoder.setSourceDevice(device)¶
- Parameters:
device –
PySide2.QtCore.QIODevice
Sets the current audio
QIODevice
todevice
.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
- PySide2.QtMultimedia.QAudioDecoder.setSourceFilename(fileName)¶
- Parameters:
fileName – str
This property holds the active filename being decoded by the decoder object..
- PySide2.QtMultimedia.QAudioDecoder.sourceChanged()¶
- PySide2.QtMultimedia.QAudioDecoder.sourceDevice()¶
- Return type:
Returns the current source
QIODevice
, if one was set. IfsetSourceFilename()
was called, this will be 0.See also
- PySide2.QtMultimedia.QAudioDecoder.sourceFilename()¶
- Return type:
str
This property holds the active filename being decoded by the decoder object..
- PySide2.QtMultimedia.QAudioDecoder.start()¶
Starts decoding the audio resource.
As data gets decoded, the
bufferReady()
signal will be emitted when enough data has been decoded. Callingread()
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
- PySide2.QtMultimedia.QAudioDecoder.state()¶
- Return type:
This property holds the audio decoder’s playback state..
By default this property is QAudioDecoder::Stopped
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.