-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsoundmanager.cpp
More file actions
77 lines (60 loc) · 1.7 KB
/
soundmanager.cpp
File metadata and controls
77 lines (60 loc) · 1.7 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "soundmanager.h"
SoundManager::SoundManager(QObject *parent) :
QObject(parent)
{
m_isSilenced = false;
mapFrame = qobject_cast<MapTilesFrame *>(parent);
routeWidget = mapFrame->findChild<RouteWidget *>();
thread = NULL;
assert(mapFrame != NULL);
assert(routeWidget != NULL);
}
bool SoundManager::isSilenced() const
{
return m_isSilenced;
}
void SoundManager::userLocationChangedSlot(QPoint point)
{
QSqlQuery query;
QString str,str1;
QString mediaSourcePath;
QPoint nearSpotLoca = routeWidget->findNearestSpotLocation(point);
double distance = mapFrame->distance(point,nearSpotLoca);
if( distance < 300 )
{
str.setNum(nearSpotLoca.x());
str1.setNum(nearSpotLoca.y());
query.exec("SELECT SoundName FROM interestNode WHERE CoordinateX="+str+" AND CoordinateY="+str1);
query.next();
if(query.isValid())
{
mediaSourcePath = mapFrame->provider().getServerAddress() + "/Sound/" + query.value(0).toString();
if(thread)
{
delete thread;
thread = NULL;
}
thread = new PlayThread(this, mediaSourcePath, isSilenced());
thread->start();
}
}
else
{
if(thread)
{
delete thread;
thread = NULL;
}
}
return ;
}
void SoundManager::setSilenced(bool isSilenced)
{
m_isSilenced = isSilenced;
if(thread)
{
//qDebug() << "setMuted: " << isSilenced;
thread->audioOutput->setMuted(isSilenced);
}
emit silenceStatusChanged(isSilenced);
}