1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QSOUNDEFFECT_H
5#define QSOUNDEFFECT_H
6
7#include <QtMultimedia/qtmultimediaglobal.h>
8#include <QtMultimedia/qaudio.h>
9#include <QtCore/qobject.h>
10#include <QtCore/qurl.h>
11#include <QtCore/qstringlist.h>
12
13
14QT_BEGIN_NAMESPACE
15
16
17class QSoundEffectPrivate;
18class QAudioDevice;
19
20class Q_MULTIMEDIA_EXPORT QSoundEffect : public QObject
21{
22 Q_OBJECT
23 Q_CLASSINFO("DefaultMethod", "play()")
24 Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
25 Q_PROPERTY(int loops READ loopCount WRITE setLoopCount NOTIFY loopCountChanged)
26 Q_PROPERTY(int loopsRemaining READ loopsRemaining NOTIFY loopsRemainingChanged)
27 Q_PROPERTY(float volume READ volume WRITE setVolume NOTIFY volumeChanged)
28 Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
29 Q_PROPERTY(bool playing READ isPlaying NOTIFY playingChanged)
30 Q_PROPERTY(Status status READ status NOTIFY statusChanged)
31 Q_PROPERTY(QAudioDevice audioDevice READ audioDevice WRITE setAudioDevice NOTIFY audioDeviceChanged)
32
33public:
34 enum Loop
35 {
36 Infinite = -2
37 };
38 Q_ENUM(Loop)
39
40 enum Status
41 {
42 Null,
43 Loading,
44 Ready,
45 Error
46 };
47 Q_ENUM(Status)
48
49 explicit QSoundEffect(QObject *parent = nullptr);
50 explicit QSoundEffect(const QAudioDevice &audioDevice, QObject *parent = nullptr);
51 ~QSoundEffect();
52
53 static QStringList supportedMimeTypes();
54
55 QUrl source() const;
56 void setSource(const QUrl &url);
57
58 int loopCount() const;
59 int loopsRemaining() const;
60 void setLoopCount(int loopCount);
61
62 QAudioDevice audioDevice();
63 void setAudioDevice(const QAudioDevice &device);
64
65 float volume() const;
66 void setVolume(float volume);
67
68 bool isMuted() const;
69 void setMuted(bool muted);
70
71 bool isLoaded() const;
72
73 bool isPlaying() const;
74 Status status() const;
75
76Q_SIGNALS:
77 void sourceChanged();
78 void loopCountChanged();
79 void loopsRemainingChanged();
80 void volumeChanged();
81 void mutedChanged();
82 void loadedChanged();
83 void playingChanged();
84 void statusChanged();
85 void audioDeviceChanged();
86
87public Q_SLOTS:
88 void play();
89 void stop();
90
91private:
92 Q_DISABLE_COPY(QSoundEffect)
93 QSoundEffectPrivate *d = nullptr;
94};
95
96QT_END_NAMESPACE
97
98
99#endif // QSOUNDEFFECT_H
100

source code of qtmultimedia/src/multimedia/audio/qsoundeffect.h