Qubet  1.0
The ultimate QGL addicting videogame!
 All Classes Functions Variables Pages
Public Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
AudioManager Class Reference

It is a semi-thread class to manage the audio of Qubet. It can manage an ambientMusic and different effects. More...

#include <audiomanager.h>

Inheritance diagram for AudioManager:
Inheritance graph
Collaboration diagram for AudioManager:
Collaboration graph

Public Member Functions

 AudioManager (QObject *_parent=0)
 Creates a new AudioManager loading all the effects in the folder resources/effects. More...
 
 ~AudioManager ()
 Safely stops and destroys the AudioManager (including the ambientMusic and all the effects in the effectsList.
 
bool isAudioEnabled ()
 Returns the state of the audio. More...
 

Private Slots

void enableAudio (bool enabled)
 Sets the variable audioEnabled and pause or continue the ambientMusic. If enabled is false and there are currently playing effects they will be stopped. More...
 
void playAmbientMusic (QString filename)
 Plays the music file provided as parameter filename as ambientMusic. More...
 
void stopAmbientMusic ()
 Stops the current ambient music.
 
void playEffect (QString effectName)
 Plays the effect that has got the parameter effectName filename. More...
 

Private Member Functions

void run ()
 It is the reimplementation of QThread's run() method. It is empty because the AudioManager is a semi-thread, all actions are managed by signals.
 

Private Attributes

QObjectparent
 
bool audioEnabled
 
QMediaPlayer * ambientMusic
 
QMediaPlaylist * playlist
 
QMap< QString, QSoundEffect * > effectsList
 

Detailed Description

It is a semi-thread class to manage the audio of Qubet. It can manage an ambientMusic and different effects.

It provides slots to connect the entity that are able to request an ambientMusic change, an effect to play or to enable and disable the music.

Version
1.0
Author
#34

Constructor & Destructor Documentation

AudioManager::AudioManager ( QObject _parent = 0)
explicit

Creates a new AudioManager loading all the effects in the folder resources/effects.

Parameters
_parentis a callback variable to the parent of AudioManager.

Member Function Documentation

void AudioManager::enableAudio ( bool  enabled)
privateslot

Sets the variable audioEnabled and pause or continue the ambientMusic. If enabled is false and there are currently playing effects they will be stopped.

Parameters
enabledis the variable to states the AudioManager to enable or disable the audio.
bool AudioManager::isAudioEnabled ( )

Returns the state of the audio.

Returns
true if audio is enabled, else false.

Here is the caller graph for this function:

void AudioManager::playAmbientMusic ( QString  filename)
privateslot

Plays the music file provided as parameter filename as ambientMusic.

It will also stop the current ambientMusic but not the effects.

Parameters
filenameis the filename of the ambientMusic to play.
void AudioManager::playEffect ( QString  effectName)
privateslot

Plays the effect that has got the parameter effectName filename.

For example if you have the file resources/effects/gameover.wav, in order to play this effect you have to call playEffect("gameover.wav").

If the effect is already playing it will be restarted.

Parameters
effectNameis the effect's filename.

Member Data Documentation

QMediaPlayer* AudioManager::ambientMusic
private

It is the QMediaPlayer of the current ambient music.

bool AudioManager::audioEnabled
private

It is the variable that states if the audio is currently enabled or not.

QMap<QString,QSoundEffect*> AudioManager::effectsList
private

It is the QMap of effects and their filename.

QObject* AudioManager::parent
private

It is a callback variable to the parent of AudioManager.

QMediaPlaylist* AudioManager::playlist
private

It is the playlist to be played as ambient music.


The documentation for this class was generated from the following files: