QAmbientSound Class
立体声叠加音效更多
头文件: | #include <QAmbientSound> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS SpatialAudio) target_link_libraries(mytarget PRIVATE Qt6::SpatialAudio) |
qmake: | QT += spatialaudio |
继承: | QObject |
公共类型
enum | Loops { Infinite, Once } |
属性
公共功能
QAmbientSound(QAudioEngine *engine) | |
bool | autoPlay() const |
QAudioEngine * | engine() const |
int | loops() const |
void | setAutoPlay(bool autoPlay) |
void | setLoops(int loops) |
void | setSource(const QUrl &url) |
void | setVolume(float volume) |
QUrl | source() const |
float | volume() const |
公共插槽
信号
void | autoPlayChanged() |
void | loopsChanged() |
void | sourceChanged() |
void | volumeChanged() |
成员类型文档
enum QAmbientSound::Loops
让您使用以下值控制循环播放:
常量 | 值 | 说明 |
---|---|---|
QAmbientSound::Infinite | -1 | 无限循环 |
QAmbientSound::Once | 1 | 运行一次后停止播放 |
属性文档
autoPlay : bool
决定在指定音源时是否自动开始播放声音。
默认值为true
。
访问功能:
bool | autoPlay() const |
void | setAutoPlay(bool autoPlay) |
通知信号:
void | autoPlayChanged() |
loops : int
决定播放器停止播放声音的次数。设置为QAmbientSound::Infinite 时,将永远循环播放当前声音。
默认值为1
。
访问功能:
int | loops() const |
void | setLoops(int loops) |
通知信号:
void | loopsChanged() |
source : QUrl
要播放的声音的源文件。
访问功能:
QUrl | source() const |
void | setSource(const QUrl &url) |
提示信号:
void | sourceChanged() |
volume : float
定义声音的音量。
0 至 1 之间的数值会减弱声音,而 1 以上的数值则会提供额外的增益提升。
访问功能
float | volume() const |
void | setVolume(float volume) |
Notifier 信号:
void | volumeChanged() |
成员函数 文档
[explicit]
QAmbientSound::QAmbientSound(QAudioEngine *engine)
为engine 创建立体声音源。
QAudioEngine *QAmbientSound::engine() const
返回与该声音相关的引擎。
[slot]
void QAmbientSound::pause()
暂停声音播放。呼叫play() 将继续播放。
[slot]
void QAmbientSound::play()
开始播放声音。如果声音已在播放,则不起任何作用。
[slot]
void QAmbientSound::stop()
停止声音播放,并将当前位置和当前循环次数重置为 0。调用play() 将从声音文件的开头开始播放。
© 2025 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.