soundplayer.h
828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef SOUNDPLAYER_H
#define SOUNDPLAYER_H
#include <QObject>
#include <QSound>
#include <QSoundEffect>
#include <QThread>
#include <QMap>
class SoundPlayWorker : public QObject
{
Q_OBJECT
public:
explicit SoundPlayWorker();
public slots:
void play(const QString &filename);
void playClick();
private:
QMap<QString, QSound *> map;
QSound *current;
QSoundEffect *click;
};
class SoundPlayer : public QObject
{
Q_OBJECT
explicit SoundPlayer();
void play(const QString &filename);
void emitClick();
static SoundPlayer *instance;
public:
static void playClick();
static void playStart();
static void playStop();
static void playError1();
static void playError2();
signals:
void operate(const QString &);
void click();
};
#endif // SOUNDPLAYER_H