- Qt 5.15
- Qt Multimedia
- QML Types
- QtMultimedia QML Type
- Qt 5.15.11 Reference Documentation

# QtMultimedia QML Type

Provides a global object with useful functions from Qt Multimedia. More...

Import Statement: | import QtMultimedia 5.15
Since: | Qt 5.4

- List of all members, including inherited members

## Properties

- availableCameras : list<object>
- defaultCamera : object

## Methods

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

## Detailed Description

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

It is not instantiable; to use it, call the members of the global `QtMultimedia` object directly. For example:

     Camera {
         deviceId: QtMultimedia.defaultCamera.deviceId
     }

## Property Documentation

[read-only] availableCameras : list<object>

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.
`position` | This read-only property holds the physical position of the camera on the hardware system. Please see Camera.position for more information.
`orientation` | This read-only property holds the physical orientation of the camera sensor. Please see Camera.orientation for more information.

Note: 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 : object

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

Its properties are `deviceId`, `displayName`, `position` and `orientation`. See availableCameras for a description of each of them.

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

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

## Method Documentation

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

Converts an audio volume from a volume scale to another, and returns the result.

Depending on the context, different scales are used to represent audio volume. All Qt Multimedia classes that have an audio volume use a linear scale, the reason is that the loudness of a speaker is controlled by modulating its voltage on a linear scale. The human ear on the other hand, perceives loudness in a logarithmic way. Using a logarithmic scale for volume controls is therefore appropriate in most applications. The decibel scale is logarithmic by nature and is commonly used to define sound levels, it is usually used for UI volume controls in professional audio applications. The cubic scale is a computationally cheap approximation of a logarithmic scale, it provides more control over lower volume levels.

Valid values for from and to are:

- QtMultimedia.LinearVolumeScale - Linear scale. `0.0` (0%) is silence and `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%) is silence and `1.0` (100%) is full volume.
- QtMultimedia.LogarithmicVolumeScale - Logarithmic scale. `0.0` (0%) is silence and `1.0` (100%) is full volume. UI volume controls should usually use a logarithmic scale.
- QtMultimedia.DecibelVolumeScale - Decibel (dB, amplitude) logarithmic scale. `-200` is silence and `0` is full volume.

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
     }

This method was introduced in Qt 5.8.