UGDK  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
music.h
Go to the documentation of this file.
1 #ifndef HORUSEYE_FRAMEWORK_MUSIC_H_
2 #define HORUSEYE_FRAMEWORK_MUSIC_H_
3 
4 #include <string>
5 #include "SDL_mixer.h"
6 
7 #include <ugdk/audio.h>
8 #include <ugdk/filesystem.h>
9 #include <memory>
10 
11 namespace ugdk {
12 namespace audio {
13 
18 class Music {
19  public:
21  void Play();
22 
24  void PlayForever();
25 
27  void Play(int loops);
28 
30  void Stop();
31 
33  bool IsPlaying() const;
34 
36  void Pause();
37 
39  void Unpause();
40 
42  bool IsPaused() const;
43 
45 
46  void SetVolume(double vol);
47 
49  double Volume();
50 
51  private:
52  Music(const std::string& filepath);
53  ~Music();
54  Mix_Music *data_;
55  double volume_;
56  std::unique_ptr<ugdk::filesystem::File> file_;
57 
58  static void UpdateVolume(double vol);
59  static void MusicDone();
60  static Music *playing_music_;
61 
62  friend class Manager;
63 };
64 
65 } // namespace audio
66 } // namespace ugdk
67 
68 #endif
void Play()
Plays this music once.
void PlayForever()
Plays this music until told to stop.
void SetVolume(double vol)
Sets the volume. 0.0 is quiet, 1.0 is the full volume.
bool IsPaused() const
Return whether this can be unpaused.
Definition: animation.h:11
Definition: music.h:18
Definition: manager.h:12
double Volume()
Returns this music's current volume, between 0.0 and 1.0.
void Stop()
Stops playing this music.
void Unpause()
Unpauses the music if it's the last played music.
void Pause()
Pauses the music, allowing it to be resumed from the same point.
bool IsPlaying() const
Return whether this music is playing or not.