MediaRecorder QML 类型

要编码和录制的媒体生成于 CaptureSession . 更多...

导入语句: import QtMultimedia
实例化: QMediaRecorder

特性

信号

方法

详细描述

The MediaRecorder element can be used within a CaptureSession to record and encode audio and video captured from a microphone and camera

The code below shows a simple capture session containing a MediaRecorder using the default camera and default audio input.

CaptureSession {
    id: captureSession
    camera: Camera {
        id: camera
    }
    audioInput: AudioInput {}
    recorder: MediaRecorder {
        id: recorder
    }
}
					

The code below shows how the recording can be started and stopped.

CameraButton {
    text: "Record"
    visible: recorder.status !== MediaRecorder.RecordingStatus
    onClicked: recorder.record()
}
CameraButton {
    id: stopButton
    text: "Stop"
    visible: recorder.status === MediaRecorder.RecordingStatus
    onClicked: recorder.stop()
}
					

另请参阅 CaptureSession , Camera , AudioInput ,和 ImageCapture .

特性文档编制

actualLocation : QUrl

The actual location of the last media content.

The actual location is usually available after recording starts, and reset when new location is set or new recording starts.

duration : qint64

This property holds the recorded media duration in milliseconds.

error : enumeration

This property holds the current media recorder error state.

常量 描述
MediaRecorder.NoError Not in an error state.
MediaRecorder.ResourceError Not enough system resources
MediaRecorder.FormatError the current format is not supported.
MediaRecorder.OutOfSpaceError No space left on device.
MediaRecorder.LocationNotWriteable The output location is not writable.

errorString : string

This property holds a string describing the current error state.

另请参阅 error .

isAvailable : bool

This property holds whether the recorder service is ready to use.

返回 true if media recorder service ready to use.

mediaFormat : MediaFormat

This property holds the current MediaFormat of the recorder.

metaData : mediaMetaData

This property holds meta data associated with the recording.

When a recording is started, any meta-data assigned will be attached to that recording.

注意: Ensure that meta-data is assigned correctly by assigning it before starting the recording.

另请参阅 mediaMetaData .

outputLocation : QUrl

The destination location of media content.

Setting the location can fail, for example when the service supports only local file system locations but a network URL was passed. If the operation fails an errorOccured() signal is emitted.

The location can be relative or empty. If empty the recorder uses the system specific place and file naming scheme.

另请参阅 errorOccurred() .

quality : enumeration

枚举品质编码级别。

常量
MediaRecorder.VeryLowQuality
MediaRecorder.LowQuality
MediaRecorder.NormalQuality
MediaRecorder.HighQuality
MediaRecorder.VeryHighQuality

recorderState : enumeration

This property holds the current media recorder state.

The state property represents the user request and is changed synchronously during record() , pause() or stop() calls. RecorderSstate may also change asynchronously when recording fails.

常量 描述
MediaRecorder.StoppedState The recorder is not active.
MediaRecorder.RecordingState The recording is requested.
MediaRecorder.PausedState The recorder is pause.

信号文档编制

actualLocationChanged (const QUrl & location )

Signals that the actual location of the recorded media has changed.

This signal is usually emitted when recording starts.

注意: 相应处理程序是 onActualLocationChanged .

durationChanged ( qint64 duration )

信号 duration of the recorded media has changed.

注意: 相应处理程序是 onDurationChanged .

errorOccurred ( Error error , const QString & errorString )

Signals that an error has occurred.

errorString contains a description of the error.

注意: 相应处理程序是 onErrorOccurred .

metaDataChanged ()

Signals that a media object's meta-data has changed.

If multiple meta-data elements are changed metaDataChanged() is emitted once.

注意: 相应处理程序是 onMetaDataChanged .

recorderStateChanged ( RecorderState state )

Signals that a media recorder's state 已改变。

注意: 相应处理程序是 onRecorderStateChanged .


方法文档编制

pause ()

暂停录制。

The recorder state is changed to QMediaRecorder .PausedState.

Depending on the platform, pausing recording may be not supported. In this case the recorder state is unchanged.

record ()

Starts recording.

While the recorder state is changed immediately to MediaRecorder.RecordingState , recording may start asynchronously.

If recording fails, the error() signal is emitted with recorder state being reset back to QMediaRecorder.StoppedState .

注意: On mobile devices, recording will happen in the orientation the device had when calling record and is locked for the duration of the recording. To avoid artifacts on the user interface, we recommend to keep the user interface locked to the same orientation as long as the recording is ongoing using the contentOrientation property of the Window and unlock it again once the recording is finished.

stop ()

停止录制。

The recorder state is changed to QMediaRecorder.StoppedState .