The QMediaRecorder class is used for the recording of media content. 更多...
| 頭: | #include <QMediaRecorder> |
| qmake: | QT += multimedia |
| 繼承: | QObject and QMediaBindableInterface |
| 繼承者: | QAudioRecorder |
| enum | Error { NoError, ResourceError, FormatError, OutOfSpaceError } |
| enum | State { StoppedState, RecordingState, PausedState } |
| enum | Status { UnavailableStatus, UnloadedStatus, LoadingStatus, LoadedStatus, ..., FinalizingStatus } |
|
|
| QMediaRecorder (QMediaObject * mediaObject , QObject * parent = Q_NULLPTR) | |
| ~QMediaRecorder () | |
| QUrl | actualLocation () const |
| QString | audioCodecDescription (const QString & codec ) const |
| QAudioEncoderSettings | audioSettings () const |
| QMultimedia::AvailabilityStatus | availability () const |
| QStringList | availableMetaData () const |
| QString | containerDescription (const QString & format ) const |
| QString | containerFormat () const |
| qint64 | duration () const |
| Error | error () const |
| QString | errorString () const |
| bool | isAvailable () const |
| bool | isMetaDataAvailable () const |
| bool | isMetaDataWritable () const |
| bool | isMuted () const |
| QVariant | metaData (const QString & key ) const |
| QUrl | outputLocation () const |
| void | setAudioSettings (const QAudioEncoderSettings & settings ) |
| void | setContainerFormat (const QString & container ) |
| void | setEncodingSettings (const QAudioEncoderSettings & audio , const QVideoEncoderSettings & 視頻 = QVideoEncoderSettings(), const QString & container = QString()) |
| void | setMetaData (const QString & key , const QVariant & value ) |
| bool | setOutputLocation (const QUrl & location ) |
| void | setVideoSettings (const QVideoEncoderSettings & settings ) |
| 狀態 | state () const |
| 狀態 | status () const |
| QStringList | supportedAudioCodecs () const |
| QList<int> | supportedAudioSampleRates (const QAudioEncoderSettings & settings = QAudioEncoderSettings(), bool * continuous = Q_NULLPTR) const |
| QStringList | supportedContainers () const |
| QList<qreal> | supportedFrameRates (const QVideoEncoderSettings & settings = QVideoEncoderSettings(), bool * continuous = Q_NULLPTR) const |
| QList<QSize> | supportedResolutions (const QVideoEncoderSettings & settings = QVideoEncoderSettings(), bool * continuous = Q_NULLPTR) const |
| QStringList | supportedVideoCodecs () const |
| QString | videoCodecDescription (const QString & codec ) const |
| QVideoEncoderSettings | videoSettings () const |
| qreal | volume () const |
| virtual QMediaObject * | mediaObject () const override |
| void | pause () |
| void | record () |
| void | setMuted (bool muted ) |
| void | setVolume (qreal volume ) |
| void | stop () |
| void | actualLocationChanged (const QUrl & location ) |
| void | availabilityChanged (bool available ) |
| void | availabilityChanged (QMultimedia::AvailabilityStatus availability ) |
| void | durationChanged (qint64 duration ) |
| void | error (QMediaRecorder::Error error ) |
| void | metaDataAvailableChanged (bool available ) |
| void | metaDataChanged () |
| void | metaDataChanged (const QString & key , const QVariant & value ) |
| void | metaDataWritableChanged (bool writable ) |
| void | mutedChanged (bool muted ) |
| void | stateChanged (QMediaRecorder::State state ) |
| void | statusChanged (QMediaRecorder::Status status ) |
| void | volumeChanged (qreal volume ) |
The QMediaRecorder class is used for the recording of media content.
The QMediaRecorder class is a high level media recording class. It's not intended to be used alone but for accessing the media recording functions of other media objects, like QRadioTuner ,或 QCamera .
recorder = new QMediaRecorder(camera); QAudioEncoderSettings audioSettings; audioSettings.setCodec("audio/amr"); audioSettings.setQuality(QMultimedia::HighQuality); recorder->setAudioSettings(audioSettings); recorder->setOutputLocation(QUrl::fromLocalFile(fileName)); recorder->record();
另請參閱 QAudioRecorder .
| 常量 | 值 | 描述 |
|---|---|---|
QMediaRecorder::NoError
|
0
|
沒有錯誤。 |
QMediaRecorder::ResourceError
|
1
|
設備未就緒 (或不可用)。 |
QMediaRecorder::FormatError
|
2
|
不支持當前格式。 |
QMediaRecorder::OutOfSpaceError
|
3
|
設備沒有剩餘空間。 |
| 常量 | 值 | 描述 |
|---|---|---|
QMediaRecorder::StoppedState
|
0
|
The recorder is not active. If this is the state after recording then the actual created recording has finished being written to the final location and is ready on all platforms except on Android. On Android, due to platform limitations, there is no way to be certain that the recording has finished writing to the final location. |
QMediaRecorder::RecordingState
|
1
|
請求錄製。 |
QMediaRecorder::PausedState
|
2
|
錄製器暫停。 |
| 常量 | 值 | 描述 |
|---|---|---|
QMediaRecorder::UnavailableStatus
|
0
|
The recorder is not available or not supported by connected media object. |
QMediaRecorder::UnloadedStatus
|
1
|
The recorder is avilable but not loaded. |
QMediaRecorder::LoadingStatus
|
2
|
The recorder is initializing. |
QMediaRecorder::LoadedStatus
|
3
|
The recorder is initialized and ready to record media. |
QMediaRecorder::StartingStatus
|
4
|
Recording is requested but not active yet. |
QMediaRecorder::RecordingStatus
|
5
|
Recording is active. |
QMediaRecorder::PausedStatus
|
6
|
Recording is paused. |
QMediaRecorder::FinalizingStatus
|
7
|
Recording is stopped with media being finalized. |
此特性保持最後媒體內容的實際位置。
The actual location is usually available after recording starts, and reset when new location is set or new recording starts.
訪問函數:
| QUrl | actualLocation () const |
通知程序信號:
| void | actualLocationChanged (const QUrl & location ) |
此特性保持錄製媒體的持續時間 (以毫秒為單位)。
訪問函數:
| qint64 | duration () const |
通知程序信號:
| void | durationChanged (qint64 duration ) |
This property holds whether access to a media object's meta-data is available.
If this is true there is meta-data available, otherwise there is no meta-data available.
訪問函數:
| bool | isMetaDataAvailable () const |
通知程序信號:
| void | metaDataAvailableChanged (bool available ) |
This property holds whether a media object's meta-data is writable.
If this is true the meta-data is writable, otherwise the meta-data is read-only.
訪問函數:
| bool | isMetaDataWritable () const |
通知程序信號:
| void | metaDataWritableChanged (bool writable ) |
This property holds whether a recording audio stream is muted.
訪問函數:
| bool | isMuted () const |
| void | setMuted (bool muted ) |
通知程序信號:
| void | mutedChanged (bool muted ) |
此特性保持媒體內容的目的地位置。
Setting the location can fail, for example when the service supports only local file system locations but a network URL was passed. If the service does not support media recording this setting the output location will always fail.
The location can be relative or empty; in this case the recorder uses the system specific place and file naming scheme. After recording has stated, QMediaRecorder::outputLocation() returns the actual output location.
訪問函數:
| QUrl | outputLocation () const |
| bool | setOutputLocation (const QUrl & location ) |
此特性保持媒體錄製器的當前狀態。
The state property represents the user request and is changed synchronously during record (), pause () 或 stop () calls. Recorder state may also change asynchronously when recording fails.
訪問函數:
| 狀態 | state () const |
通知程序信號:
| void | stateChanged (QMediaRecorder::State state ) |
This property holds the current status of the media recorder.
The status is changed asynchronously and represents the actual status of media recorder.
訪問函數:
| 狀態 | status () const |
通知程序信號:
| void | statusChanged (QMediaRecorder::Status status ) |
This property holds the current recording audio volume.
按綫性比例縮放的音量是從
0.0
(無聲) 到
1.0
(全音量)。將鉗製超齣此範圍的值。
默認音量為
1.0
.
通常,UI 音量控件應按非綫性比例縮放。例如,使用對數比例縮放將産生感知響度的綫性變化,這通常是用戶期望的音量控製。見 QAudio::convertVolume () 瞭解更多細節。
訪問函數:
| qreal | volume () const |
| void | setVolume (qreal volume ) |
通知程序信號:
| void | volumeChanged (qreal volume ) |
Constructs a media recorder which records the media produced by mediaObject .
The parent 被傳遞給 QMediaObject .
銷毀媒體錄製器對象。
[signal]
void
QMediaRecorder::
actualLocationChanged
(const
QUrl
&
location
)
Signals that the actual location of the recorded media has changed. This signal is usually emitted when recording starts.
注意: 通知程序信號對於特性 actualLocation .
Returns a description of an audio codec .
Returns the audio encoder settings being used.
另請參閱 setAudioSettings () 和 setEncodingSettings ().
Returns the availability of this functionality.
另請參閱 availabilityChanged ().
[signal]
void
QMediaRecorder::
availabilityChanged
(
bool
available
)
Signals that the media recorder is now available (if available is true), or not.
注意: 信號 availabilityChanged 在此類中是重載。要使用函數指針句法連接到此信號,必須在靜態鑄造中指定信號類型,如此範例所示:
connect(mediaRecorder, static_cast<void(QMediaRecorder::*)(bool)>(&QMediaRecorder::availabilityChanged), [=](bool available){ /* ... */ });
[signal]
void
QMediaRecorder::
availabilityChanged
(
QMultimedia::AvailabilityStatus
availability
)
Signals that the service availability has changed to availability .
注意: 信號 availabilityChanged 在此類中是重載。要使用函數指針句法連接到此信號,必須在靜態鑄造中指定信號類型,如此範例所示:
connect(mediaRecorder, static_cast<void(QMediaRecorder::*)(QMultimedia::AvailabilityStatus)>(&QMediaRecorder::availabilityChanged), [=](QMultimedia::AvailabilityStatus availability){ /* ... */ });
返迴元數據的可用鍵列錶。
Returns a description of a container format .
Returns the selected container format.
另請參閱 setContainerFormat ().
[signal]
void
QMediaRecorder::
durationChanged
(
qint64
duration
)
發射信號,當 duration of the recorded media has changed.
注意: 通知程序信號對於特性 duration .
返迴當前錯誤狀態。
另請參閱 errorString ().
[signal]
void
QMediaRecorder::
error
(
QMediaRecorder::Error
error
)
發射信號,當 error has occurred.
注意: 信號 error 在此類中是重載。要使用函數指針句法連接到此信號,必須在靜態鑄造中指定信號類型,如此範例所示:
connect(mediaRecorder, static_cast<void(QMediaRecorder::*)(QMediaRecorder::Error)>(&QMediaRecorder::error), [=](QMediaRecorder::Error error){ /* ... */ });
返迴描述當前錯誤狀態的字符串。
另請參閱 error ().
Returns true if media recorder service ready to use.
另請參閱 availabilityChanged ().
[override virtual]
QMediaObject
*QMediaRecorder::
mediaObject
() const
重實現自 QMediaBindableInterface::mediaObject ().
返迴 QMediaObject instance that this QMediaRecorder is bound too, or 0 otherwise.
返迴的值關聯元數據 key .
另請參閱 setMetaData ().
[signal]
void
QMediaRecorder::
metaDataAvailableChanged
(
bool
available
)
發射信號,當 available state of a media object's meta-data has changed.
注意: 通知程序信號對於特性 metaDataAvailable .
[signal]
void
QMediaRecorder::
metaDataChanged
()
Signals that a media object's meta-data has changed.
If multiple meta-data elements are changed, metaDataChanged(const QString &key, const QVariant &value) signal is emitted for each of them with metaDataChanged() changed emitted once.
注意: 信號 metaDataChanged 在此類中是重載。要使用函數指針句法連接到此信號,必須在靜態鑄造中指定信號類型,如此範例所示:
connect(mediaRecorder, static_cast<void(QMediaRecorder::*)()>(&QMediaRecorder::metaDataChanged), [=](){ /* ... */ });
[signal]
void
QMediaRecorder::
metaDataChanged
(const
QString
&
key
, const
QVariant
&
value
)
Signal the changes of one meta-data element value 采用給定 key .
注意: 信號 metaDataChanged 在此類中是重載。要使用函數指針句法連接到此信號,必須在靜態鑄造中指定信號類型,如此範例所示:
connect(mediaRecorder, static_cast<void(QMediaRecorder::*)(const QString &, const QVariant &)>(&QMediaRecorder::metaDataChanged), [=](const QString &key, const QVariant &value){ /* ... */ });
[signal]
void
QMediaRecorder::
metaDataWritableChanged
(
bool
writable
)
發射信號,當 writable state of a media object's meta-data has changed.
注意: 通知程序信號對於特性 metaDataWritable .
[signal]
void
QMediaRecorder::
mutedChanged
(
bool
muted
)
發射信號,當 muted state has changed. If true the recording is being muted.
注意: 通知程序信號對於特性 muted .
[slot]
void
QMediaRecorder::
pause
()
Pause recording.
The recorder state is changed to QMediaRecorder::PausedState .
Depending on platform recording pause may be not supported, in this case the recorder state stays unchanged.
[slot]
void
QMediaRecorder::
record
()
開始錄製。
While the recorder state is changed immediately to QMediaRecorder::RecordingState , recording may start asynchronously, with statusChanged ( QMediaRecorder::RecordingStatus ) signal emitted when recording starts.
若錄製失敗 error () signal is emitted with recorder state being reset back to QMediaRecorder::StoppedState .
Sets the audio encoder settings .
If some parameters are not specified, or null settings are passed, the encoder will choose default encoding parameters, depending on media source properties.
It's only possible to change settings when the encoder is in the QMediaEncoder::StoppedState state.
另請參閱 audioSettings (), videoSettings (),和 containerFormat ().
Sets the media container 格式。
If the container format is not specified, the encoder will choose format, depending on media source properties and encoding settings selected.
It's only possible to change settings when the encoder is in the QMediaEncoder::StoppedState state.
另請參閱 audioSettings (), videoSettings (),和 containerFormat ().
設置 audio and 視頻 encoder settings and container 格式。
If some parameters are not specified, or null settings are passed, the encoder will choose default encoding parameters, depending on media source properties.
It's only possible to change settings when the encoder is in the QMediaEncoder::StoppedState state.
另請參閱 audioSettings (), videoSettings (),和 containerFormat ().
設置 value for a meta-data key .
注意: To ensure that meta data is set corretly, it should be set before starting the recording. Once the recording is stopped, any meta data set will be attached to the next recording.
另請參閱 metaData ().
Sets the video encoder settings .
If some parameters are not specified, or null settings are passed, the encoder will choose default encoding parameters, depending on media source properties.
It's only possible to change settings when the encoder is in the QMediaEncoder::StoppedState state.
另請參閱 audioSettings (), videoSettings (),和 containerFormat ().
Returns the current media recorder state.
注意: getter 函數對於特性 state .
另請參閱 QMediaRecorder::State .
[signal]
void
QMediaRecorder::
stateChanged
(
QMediaRecorder::State
state
)
Signals that a media recorder's state 已改變。
注意: 通知程序信號對於特性 state .
Returns the current media recorder status.
注意: getter 函數對於特性 status .
另請參閱 QMediaRecorder::Status .
[slot]
void
QMediaRecorder::
stop
()
Stop recording.
The recorder state is changed to QMediaRecorder::StoppedState .
Returns a list of supported audio codecs.
Returns a list of supported audio sample rates.
If non null audio settings parameter is passed, the returned list is reduced to sample rates supported with partial settings applied.
This can be used to query the list of sample rates, supported by specific audio codec.
If the encoder supports arbitrary sample rates within the supported rates range, * continuous 被設為 true,否則 * continuous 被設為 false。
Returns a list of supported container formats.
Returns a list of frame rates video can be encoded at.
If non null video settings parameter is passed, the returned list is reduced to frame rates supported with partial settings like video codec or resolution applied.
If the encoder supports arbitrary frame rates within the supported range, * continuous 被設為 true,否則 * continuous 被設為 false。
另請參閱 QVideoEncoderSettings::frameRate ().
Returns a list of resolutions video can be encoded at.
If non null video settings parameter is passed, the returned list is reduced to resolution supported with partial settings like video codec or framerate applied.
If the encoder supports arbitrary resolutions within the supported range, * continuous 被設為 true,否則 * continuous 被設為 false。
另請參閱 QVideoEncoderSettings::resolution ().
Returns a list of supported video codecs.
Returns a description of a video codec .
另請參閱 setEncodingSettings ().
Returns the video encoder settings being used.
另請參閱 setVideoSettings () 和 setEncodingSettings ().