QAmbientSound Class

A stereo overlay sound. 更多...

頭: #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 pause ()
void play ()
void stop ()

信號

void autoPlayChanged ()
void loopsChanged ()
void sourceChanged ()
void volumeChanged ()

詳細描述

QAmbientSound represents a position and orientation independent sound. It's commonly used for background sounds (e.g. music) that is supposed to be independent of the listeners position and orientation.

成員類型文檔編製

enum QAmbientSound:: Loops

Lets you control the playback loop using the following values:

常量 描述
QAmbientSound::Infinite -1 Loops infinitely
QAmbientSound::Once 1 Stops playback after running once

特性文檔編製

autoPlay : bool

Determines whether the sound should automatically start playing when a source gets specified.

默認值為 true .

訪問函數:

bool autoPlay () const
void setAutoPlay (bool autoPlay )

通知程序信號:

void autoPlayChanged ()

loops : int

Determines how many times the sound is played before the player stops. Set to QAmbientSound::Infinite to play the current sound in a loop forever.

默認值為 1 .

訪問函數:

int loops () const
void setLoops (int loops )

通知程序信號:

void loopsChanged ()

source : QUrl

The source file for the sound to be played.

訪問函數:

QUrl source () const
void setSource (const QUrl & url )

通知程序信號:

void sourceChanged ()

volume : float

Defines the volume of the sound.

Values between 0 and 1 will attenuate the sound, while values above 1 provide an additional gain boost.

訪問函數:

float volume () const
void setVolume (float volume )

通知程序信號:

void volumeChanged ()

成員函數文檔編製

[explicit] QAmbientSound:: QAmbientSound ( QAudioEngine * engine )

Creates a stereo sound source for engine .

QAudioEngine *QAmbientSound:: engine () const

Returns the engine associated with this sound.

[slot] void QAmbientSound:: pause ()

Pauses sound playback. Calling play () will continue playback.

[slot] void QAmbientSound:: play ()

Starts playing back the sound. Does nothing if the sound is already playing.

[slot] void QAmbientSound:: stop ()

Stops sound playback and resets the current position and current loop count to 0. Calling play () will start playback at the beginning of the sound file.