The QAudioDecoder class allows decoding audio. 更多...
| 頭: | #include <QAudioDecoder> |
| qmake: | QT += multimedia |
| 繼承: | QMediaObject |
該類在開發且可能改變。
| enum | Error { NoError, ResourceError, FormatError, AccessDeniedError, ServiceMissingError } |
| enum | State { StoppedState, DecodingState } |
| QAudioDecoder (QObject * parent = Q_NULLPTR) | |
| ~QAudioDecoder () | |
| QAudioFormat | audioFormat () const |
| 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 () const |
| void | start () |
| void | stop () |
| 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 ) |
| QMultimedia::SupportEstimate | hasSupport (const QString & mimeType , const QStringList & codecs = QStringList()) |
The QAudioDecoder class allows decoding audio.
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.
另請參閱 QAudioBuffer .
定義媒體播放器錯誤條件。
| 常量 | 值 | 描述 |
|---|---|---|
QAudioDecoder::NoError
|
0
|
沒有齣現錯誤。 |
QAudioDecoder::ResourceError
|
1
|
無法解析媒體資源。 |
QAudioDecoder::FormatError
|
2
|
媒體資源格式不支持。 |
QAudioDecoder::AccessDeniedError
|
3
|
沒有適當權限來播放媒體資源。 |
QAudioDecoder::ServiceMissingError
|
4
|
找不到有效迴放服務,無法繼續進行播放。開頭 |
定義媒體播放器的當前狀態。
| 常量 | 值 | 描述 |
|---|---|---|
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. |
This property holds whether there is a decoded audio buffer available
訪問函數:
| bool | bufferAvailable () const |
通知程序信號:
| void | bufferAvailableChanged (bool available ) |
此特性保持描述最後一個錯誤條件的字符串。
訪問函數:
| QString | errorString () const |
另請參閱 error ().
This property holds the active filename being decoded by the decoder object.
訪問函數:
| QString | sourceFilename () const |
| void | setSourceFilename (const QString & fileName ) |
通知程序信號:
| void | sourceChanged () |
This property holds the audio decoder's playback state.
By default this property is QAudioDecoder::Stopped
訪問函數:
| 狀態 | state () const |
通知程序信號:
| void | stateChanged (QAudioDecoder::State state ) |
Construct an QAudioDecoder instance parented to parent .
銷毀音頻解碼器對象。
Returns the current audio format of the decoded stream.
Any buffers returned should have this format.
另請參閱 setAudioFormat () 和 formatChanged ().
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 函數對於特性 bufferAvailable .
[signal]
void
QAudioDecoder::
bufferAvailableChanged
(
bool
available
)
Signals the availability (if available is true) of a new buffer.
若 available is false, there are no buffers available.
注意: 通知程序信號對於特性 bufferAvailable .
另請參閱 bufferAvailable () 和 bufferReady ().
[signal]
void
QAudioDecoder::
bufferReady
()
Signals that a new decoded audio buffer is available to be read.
另請參閱 read () 和 bufferAvailable ().
Returns total duration (in milliseconds) of the audio stream or -1 if not available.
[signal]
void
QAudioDecoder::
durationChanged
(
qint64
duration
)
Signals that the estimated duration of the decoded data has changed.
另請參閱 positionChanged ().
返迴當前錯誤狀態。
[signal]
void
QAudioDecoder::
error
(
QAudioDecoder::Error
error
)
發射信號,當 error 條件齣現。
注意: 信號 error 在此類中是重載。要使用函數指針句法連接到此信號,必須在靜態鑄造中指定信號類型,如此範例所示:
connect(audioDecoder, static_cast<void(QAudioDecoder::*)(QAudioDecoder::Error)>(&QAudioDecoder::error), [=](QAudioDecoder::Error error){ /* ... */ });
另請參閱 errorString ().
[signal]
void
QAudioDecoder::
finished
()
Signals that the decoding has finished successfully. If decoding fails, error signal is emitted instead.
另請參閱 start (), stop (),和 error ().
[signal]
void
QAudioDecoder::
formatChanged
(const
QAudioFormat
&
format
)
Signals that the current audio format of the decoder has changed to format .
另請參閱 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 和一組 codecs .
Returns position (in milliseconds) of the last buffer read from the decoder or -1 if no buffers have been read.
[signal]
void
QAudioDecoder::
positionChanged
(
qint64
position
)
Signals that the current position of the decoder has changed.
另請參閱 durationChanged ().
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.
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
() 會被設為
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 .
另請參閱 audioFormat ().
設置當前音頻 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.
另請參閱 sourceDevice ().
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 函數對於特性 sourceFilename .
另請參閱 sourceFilename ().
[signal]
void
QAudioDecoder::
sourceChanged
()
Signals that the current source of the decoder has changed.
注意: 通知程序信號對於特性 sourceFilename .
另請參閱 sourceFilename () 和 sourceDevice ().
返迴當前源 QIODevice , if one was set. If setSourceFilename () was called, this will be 0.
另請參閱 setSourceDevice ().
Returns the current file name to decode. If setSourceDevice was called, this will be empty.
注意: getter 函數對於特性 sourceFilename .
另請參閱 setSourceFilename ().
[slot]
void
QAudioDecoder::
start
()
開始解碼音頻資源。
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.
若調用 read () before a buffer is ready, an invalid buffer will be returned, again without blocking.
另請參閱 read ().
[signal]
void
QAudioDecoder::
stateChanged
(
QAudioDecoder::State
state
)
發射信號,當 state of the decoder object has changed.
注意: 通知程序信號對於特性 state .
[slot]
void
QAudioDecoder::
stop
()
停止解碼音頻。調用 start () again will resume decoding from the beginning.