-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSoundEffects.cpp
More file actions
38 lines (35 loc) · 1007 Bytes
/
SoundEffects.cpp
File metadata and controls
38 lines (35 loc) · 1007 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
#include "SoundEffects.h"
#include <QDebug>
SoundEffects::SoundEffects()
{
qRegisterMetaType<SoundId>("SoundId");
url[CLICKED] = QUrl::fromLocalFile(":/sounds/clicked.wav");
url[FOUND] = QUrl::fromLocalFile(":/sounds/found.wav");
url[NOTFOUND] = QUrl::fromLocalFile(":/sounds/notfound.wav");
url[FINISHED] = QUrl::fromLocalFile(":/sounds/finished.wav");
url[START] = QUrl::fromLocalFile(":/sounds/start.wav");
url[NEWDEAL] = QUrl::fromLocalFile(":/sounds/newDeal.wav");
for (int i = 0; i < 6; i++)
{
effect[i] = new QSoundEffect;
effect[i]->setSource(url[i]);
effect[i]->setVolume(1);
effect[i]->setLoopCount(1);
}
}
SoundEffects::~SoundEffects()
{
for (int i = 0; i < 6; i++)
delete effect[i];
}
void SoundEffects::play(SoundId id)
{
if (effect[id]->isPlaying()){
effect[id]->stop();
effect[id]->play();
}
else
{
effect[id]->play();
}
}