MediaDevices QML Type
MediaDevices 提供了有关可用多媒体输入和输出设备的信息。更多...
| Import Statement: | import QtMultimedia |
| In C++: | QMediaDevices |
属性
- audioInputs : list<audioDevice>
- audioOutputs : list<audioDevice>
- defaultAudioInput : audioDevice
- defaultAudioOutput : audioDevice
- defaultVideoInput : cameraDevice
- videoInputs : list<cameraDevice>
详细说明
MediaDevices 类型提供了有关可用多媒体设备及系统默认设置的信息。它监控以下三类设备:
- 音频输入设备(麦克风)
- 音频输出设备(扬声器、耳机)
- 视频输入设备(摄像头)
MediaDevices 为每个设备组提供独立的列表。如果检测到新设备已连接到系统,或已连接的设备已从系统断开,它将更新相应的设备列表,并发出信号通知该变更。
MediaDevices 会监控每个设备组的系统默认设置,并会通知通过系统设置所做的任何更改。 例如,如果用户在系统设置中选择了新的默认音频输出设备,MediaDevices 将相应地更新默认音频输出并发出信号。如果系统未为摄像头或音频输入提供默认设备,MediaDevices 将从列表中选择第一个设备作为默认设备。
虽然使用默认的输入和输出设备通常足以满足多媒体的播放或录制需求,但有时仍需要显式指定要使用的设备。
例如,下面的代码片段将确保媒体播放器在播放时始终使用系统的默认音频输出设备:
MediaDevices {
id: devices
}
MediaPlayer {
...
audioOutput: AudioOutput {
device: devices.defaultAudioOutput
}
}另请参阅 Camera 、AudioInput 以及VideoOutput 。
属性文档
audioInputs : list<audioDevice> [read-only]
包含系统中可用音频输入设备的列表。
这些设备通常是麦克风。设备可以是内置的,也可以是通过 USB 或蓝牙等方式连接的。
audioOutputs : list<audioDevice> [read-only]
包含系统中可用音频输出设备的列表。
这些设备通常是扬声器或耳机。设备可以是内置的,也可以是通过 USB 或蓝牙等方式连接的。
defaultAudioInput : audioDevice [read-only]
返回默认的音频输入设备。
在应用程序运行期间,默认设备可能会发生变化。该属性的值会自动根据这些变化进行调整。
defaultAudioOutput : audioDevice [read-only]
返回默认的音频输出设备。
在应用程序运行期间,默认设备可能会发生变化。该属性的值会根据这些变化自动调整。
defaultVideoInput : cameraDevice [read-only]
返回系统上的默认摄像头。
注意: 在使用返回的对象 之前,应先通过 isNull() 进行检查,以防没有可用的摄像头。
在应用程序运行期间,默认设备可能会发生变化。该属性的值会自动根据这些变化进行调整。
videoInputs : list<cameraDevice> [read-only]
包含系统中的摄像头列表。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.