1 | // Copyright (C) 2022 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-3.0-only |
3 | #ifndef QAMBIENTSOUND_H |
4 | #define QAMBIENTSOUND_H |
5 | |
6 | #include <QtSpatialAudio/qtspatialaudioglobal.h> |
7 | #include <QtMultimedia/qtmultimediaglobal.h> |
8 | #include <QtCore/QUrl> |
9 | #include <QtCore/QObject> |
10 | |
11 | QT_BEGIN_NAMESPACE |
12 | |
13 | class QAudioEngine; |
14 | class QAmbientSoundPrivate; |
15 | |
16 | class Q_SPATIALAUDIO_EXPORT QAmbientSound : public QObject |
17 | { |
18 | Q_OBJECT |
19 | Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) |
20 | Q_PROPERTY(float volume READ volume WRITE setVolume NOTIFY volumeChanged) |
21 | Q_PROPERTY(int loops READ loops WRITE setLoops NOTIFY loopsChanged) |
22 | Q_PROPERTY(bool autoPlay READ autoPlay WRITE setAutoPlay NOTIFY autoPlayChanged) |
23 | |
24 | public: |
25 | explicit QAmbientSound(QAudioEngine *engine); |
26 | ~QAmbientSound(); |
27 | |
28 | void setSource(const QUrl &url); |
29 | QUrl source() const; |
30 | |
31 | enum Loops |
32 | { |
33 | Infinite = -1, |
34 | Once = 1 |
35 | }; |
36 | Q_ENUM(Loops) |
37 | |
38 | int loops() const; |
39 | void setLoops(int loops); |
40 | |
41 | bool autoPlay() const; |
42 | void setAutoPlay(bool autoPlay); |
43 | |
44 | void setVolume(float volume); |
45 | float volume() const; |
46 | |
47 | QAudioEngine *engine() const; |
48 | |
49 | Q_SIGNALS: |
50 | void sourceChanged(); |
51 | void loopsChanged(); |
52 | void autoPlayChanged(); |
53 | void volumeChanged(); |
54 | |
55 | public Q_SLOTS: |
56 | void play(); |
57 | void pause(); |
58 | void stop(); |
59 | |
60 | private: |
61 | void setEngine(QAudioEngine *engine); |
62 | friend class QAmbientSoundPrivate; |
63 | QAmbientSoundPrivate *d = nullptr; |
64 | }; |
65 | |
66 | QT_END_NAMESPACE |
67 | |
68 | #endif |
69 |