QtMultimedia QML Type

Provides a global object with useful functions from Qt Multimedia. 更多...

import 语句: import QtMultimedia 5.8
Since: QtMultimedia 5.4

特性

方法

详细描述

The QtMultimedia object is a global object with utility functions and properties.

它不可实例化;要使用它,调用成员来自全局 QtMultimedia 对象直接。例如:

Camera {
    deviceId: QtMultimedia.defaultCamera.deviceId
}
					

特性文档编制

[read-only] availableCameras : list < 对象 >

This property provides information about the cameras available on the system.

Each object in the list has the following properties:

deviceId

This read-only property holds the unique identifier of the camera.

You can choose which device to use with a Camera object by setting its deviceId property to this value.

displayName This read-only property holds the human-readable name of the camera. You can use this property to display the name of the camera in a user interface.
位置 This read-only property holds the physical position of the camera on the hardware system. Please see Camera.position 了解更多信息。
orientation This read-only property holds the physical orientation of the camera sensor. Please see Camera.orientation 了解更多信息。

注意: This property is static; it is not updated when cameras are added or removed from the system, like USB cameras on a desktop platform.

The following example shows how to display a list of available cameras. The user can change the active camera by selecting one of the items in the list.

Item {
    Camera {
        id: camera
    }
    VideoOutput {
        anchors.fill: parent
        source: camera
    }
    ListView {
        anchors.fill: parent
        model: QtMultimedia.availableCameras
        delegate: Text {
            text: modelData.displayName
            MouseArea {
                anchors.fill: parent
                onClicked: camera.deviceId = modelData.deviceId
            }
        }
    }
}
							

[read-only] defaultCamera : 对象

The defaultCamera object provides information about the default camera on the system.

Its properties are deviceId , displayName , 位置 and orientation 。见 availableCameras for a description of each of them.

If there is no default camera, defaultCamera.deviceId will contain an empty string.

注意: This property is static; it is not updated if the system's default camera changes after the application started.


方法文档编制

real convertVolume ( real volume , VolumeScale from , VolumeScale to )

转换音频 volume from 音量比例缩放 to 另一,并返回结果。

从属上下文,表示音频音量是使用不同刻度。所有拥有音频音量的 Qt Multimedia 类都使用线性刻度,原因是扬声器响度是通过线性刻度调制其电压来控制的。另一方面,人的耳朵以对数方式感知响度。因此,在大多数应用程序中,音量控制使用对数刻度很合适。分贝刻度本质上是对数的,且常用于定义声明级别,通常用于专业音频应用程序 UI 音量控制。立方刻度是对数刻度的便宜计算近似,它提供对较低音量级别的更多控制。

Valid values for from and to 是:

  • QtMultimedia .LinearVolumeScale - Linear scale. 0.0 (0%) 为无声而 1.0 (100%) is full volume. All Qt Multimedia types that have an audio volume use a linear scale.
  • QtMultimedia .CubicVolumeScale - Cubic scale. 0.0 (0%) 为无声而 1.0 (100%) 为全音量。
  • QtMultimedia .LogarithmicVolumeScale - Logarithmic scale. 0.0 (0%) 为无声而 1.0 (100%) is full volume. UI volume controls should usually use a logarithmic scale.
  • QtMultimedia .DecibelVolumeScale - Decibel (dB, amplitude) logarithmic scale. -200 为无声而 0 为全音量。

The following example shows how the volume value from a UI volume control can be converted so that the perceived increase in loudness is the same when increasing the volume control from 0.2 to 0.3 as it is from 0.5 to 0.6:

Slider {
    id: volumeSlider
    property real volume: QtMultimedia.convertVolume(volumeSlider.value,
                                                     QtMultimedia.LogarithmicVolumeScale,
                                                     QtMultimedia.LinearVolumeScale)
}
MediaPlayer {
    volume: volumeSlider.volume
}
									

该 QML 方法在 Qt 5.8 引入。