Qubet  1.0
The ultimate QGL addicting videogame!
 All Classes Functions Variables Pages
audiomanager.h
1 // Qubet - Copyright (C) 2011
2 // Enrico Bacis
3 // Daniele Ciriello
4 
5 // Qubet is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18 
19 #ifndef AUDIOMANAGER_H
20 #define AUDIOMANAGER_H
21 
22 #include <QThread>
23 #include <QMediaPlayer>
24 #include <QSoundEffect>
25 #include <QMediaPlaylist>
26 
37 class AudioManager : public QThread
38 {
39  Q_OBJECT
40 
41 public:
42 
48  explicit AudioManager(QObject *_parent = 0);
49 
54  ~AudioManager();
55 
61  bool isAudioEnabled();
62 
63 
64 private:
65 
67  bool audioEnabled;
68  QMediaPlayer *ambientMusic;
69  QMediaPlaylist *playlist;
70  QMap<QString,QSoundEffect*> effectsList;
76  void run();
77 
78 
79 private slots:
80 
87  void enableAudio(bool enabled);
88 
96  void playAmbientMusic(QString filename);
97 
101  void stopAmbientMusic();
102 
113  void playEffect(QString effectName);
114 
115 };
116 
117 #endif // AUDIOMANAGER_H
It is a semi-thread class to manage the audio of Qubet. It can manage an ambientMusic and different e...
Definition: audiomanager.h:37
bool audioEnabled
Definition: audiomanager.h:67
void stopAmbientMusic()
Stops the current ambient music.
Definition: audiomanager.cpp:110
~AudioManager()
Safely stops and destroys the AudioManager (including the ambientMusic and all the effects in the eff...
Definition: audiomanager.cpp:49
void playEffect(QString effectName)
Plays the effect that has got the parameter effectName filename.
Definition: audiomanager.cpp:115
QMap< QString, QSoundEffect * > effectsList
Definition: audiomanager.h:70
bool isAudioEnabled()
Returns the state of the audio.
Definition: audiomanager.cpp:72
QMediaPlayer * ambientMusic
Definition: audiomanager.h:68
QObject * parent
Definition: audiomanager.h:66
void run()
It is the reimplementation of QThread's run() method. It is empty because the AudioManager is a semi-...
Definition: audiomanager.cpp:129
void playAmbientMusic(QString filename)
Plays the music file provided as parameter filename as ambientMusic.
Definition: audiomanager.cpp:97
void enableAudio(bool enabled)
Sets the variable audioEnabled and pause or continue the ambientMusic. If enabled is false and there ...
Definition: audiomanager.cpp:77
AudioManager(QObject *_parent=0)
Creates a new AudioManager loading all the effects in the folder resources/effects.
Definition: audiomanager.cpp:23
QMediaPlaylist * playlist
Definition: audiomanager.h:69