summaryrefslogtreecommitdiffstats
path: root/pacman-c++/audioplayer.h
blob: dd0c25a688f6a671393e78dea09ab2b26a39fb09 (plain)
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
#ifndef AUDIOPLAYER_H
#define AUDIOPLAYER_H

#include <QObject>
#include <QList>
#include <QFile>
#include <phonon/phononnamespace.h>

namespace Phonon
{
  class MediaObject;
  class AudioOutput;
}

class AudioPlayer
  : public QObject
{
  Q_OBJECT

public:
  enum Sound {
    Intro = 0,
    WakaWaka,
    EatingCherry,
    Die
  };

public:
  AudioPlayer();
  static AudioPlayer *self();
  bool isWorking();
  void stop();
  void setMuted(bool mute = true);
  void play(Sound sound);
  void clear();
  void enqueue(Sound sound);
  void clearQueue();
  Phonon::State state();

signals:
  void finished();
  void aboutToFinish();

private:
  void test();
  void preload();

private slots:
  void finished_p();
  void aboutToFinish_p();
  void stateChanged_p(Phonon::State newstate, Phonon::State oldstate);
  void testFinished();

private:
  bool m_working;
  Phonon::MediaObject *m_player;
  Phonon::AudioOutput *m_output;
  static AudioPlayer *m_instance;
  QList<QFile *> m_sounds;
};

#endif // AUDIOPLAYER_H