Spinning Topp Logo BlackTopp Studios
inc
musicplayer.h
Go to the documentation of this file.
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef _audiomusicplayer_h
41 #define _audiomusicplayer_h
42 
43 #include "datatypes.h"
44 
45 /// @file
46 /// @brief The interface for the Musicplayer class
47 
48 namespace Mezzanine
49 {
50  namespace Audio
51  {
52  class Playlist;
53  class iSound;
54  ///////////////////////////////////////////////////////////////////////////////
55  /// @brief This is a convenience class for the playing of music in a game.
56  /// @details
57  ///////////////////////////////////////
59  {
60  public:
61  /// @brief Convenience type for track iterators from playlists.
62  typedef std::list<Audio::iSound*>::iterator TrackIterator;
63  protected:
64  /// @internal
65  /// @brief A pointer to the active playlist used by this player.
67  /// @internal
68  /// @brief A pointer to the currently selected track.
70  /// @internal
71  /// @brief Stores whether or not the current track has been manually stopped.
73  /// @internal
74  /// @brief Stores whether or not this player is currently playing.
76  /// @internal
77  /// @brief Stores whether or not the player will loop back to the start when it finishes playing all tracks in the playlist.
79  /// @internal
80  /// @brief Stores whether or not the player will shuffle the playlist when it finishes playing all the tracks in the playlist.
82 
83  /// @internal
84  /// @brief Gets an iterator to the iSound instance in the current playlist.
85  /// @param Track The iSound instance to get an iterator to.
86  /// @return Returns a TrackIterator to the specified iSound in the currenlt playlist.
87  TrackIterator GetIteratorToTrack(iSound* Track);
88  public:
89  /// @brief Class constructor.
90  MusicPlayer();
91  /// @brief Class destructor.
92  ~MusicPlayer();
93 
94  ///////////////////////////////////////////////////////////////////////////////
95  // Playback and Selection
96 
97  /// @brief Plays the current selection.
98  /// @throw If the current playlist is empty this throws a @ref InvalidStateException
99  void Play();
100  /// @brief Stops the current selection.
101  void Stop();
102  /// @brief Pauses the current selection.
103  void Pause();
104  /// @brief Advances to the next selection on the playlist.
105  void Next();
106  /// @brief Moves back to the previous selection on the playlist.
107  void Previous();
108 
109  /// @brief Sets the specified track as the current track.
110  /// @throw If the provided track isn't in the playlist, this will throw an @ref InstanceIdentityNotFoundException . Use the ContainsSong() function to verify before using this.
111  /// @param Track The track to set.
112  void SwitchToTrack(iSound* Track);
113 
114  ///////////////////////////////////////////////////////////////////////////////
115  // Checks
116 
117  /// @brief Gets whether or not the current selection is playing.
118  /// @return Returns true if the current track is playing, false otherwise.
119  Boole IsPlaying() const;
120  /// @brief Gets whether or not the current selection is stopped.
121  /// @return Returns true if the current track is stopped, false otherwise.
122  Boole IsStopped() const;
123  /// @brief Gets whether or not the current selection is paused.
124  /// @return Returns true if the current track is paused, false otherwise.
125  Boole IsPaused() const;
126  /// @brief Checks the set playlist to see if it contains a track.
127  /// @param Track The track to check for.
128  /// @return Returns true if the current playlist contains the specified song, false otherwise.
129  Boole ContainsSong(iSound* Track) const;
130 
131  ///////////////////////////////////////////////////////////////////////////////
132  // Configuration
133 
134  /// @brief Sets whether the playlist should return to the start after it reaches the end of the list.
135  /// @param Repeat Enables/Disables repeating the playlist when it reaches the end.
136  void SetPlaylistRepeat(Boole Repeat);
137  /// @brief Gets wether playlist repeat is enabled.
138  /// @return Returns true if the playlist is set to repeat when it finishes, false otherwise.
139  Boole GetPlaylistRepeat() const;
140  /// @brief Sets whether the playlist should shuffle it's contents after it reaches the end of the list.
141  /// @param Shuffle Enables/Disables shuffling the playlist when it reaches the end.
142  void SetPlaylistShuffle(Boole Shuffle);
143  /// @brief Gets wether playlist shuffle is enabled.
144  /// @return Returns true if the playlist is set to shuffle when it finishes, false otherwise.
145  Boole GetPlaylistShuffle() const;
146 
147  ///////////////////////////////////////////////////////////////////////////////
148  // Utility
149 
150  /// @brief Gets the playlist in use by this music player.
151  /// @return Returns a pointer to the current playlist in use.
152  Playlist* GetPlaylist() const;
153  /// @brief Called on by the AudioManager to perform all music player responsibilities.
154  void Update();
155  };//MusicPlayer
156  }//Audio
157 }//Mezzanine
158 
159 #endif
This is a convenience class for the playing of music in a game.
Definition: musicplayer.h:58
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
All the definitions for datatypes as well as some basic conversion functions are defined here...
Boole EOPRepeat
Stores whether or not the player will loop back to the start when it finishes playing all tracks in t...
Definition: musicplayer.h:78
Audio::iSound * CurrTrack
A pointer to the currently selected track.
Definition: musicplayer.h:69
This is an interface class for a non-spacialized sound.
Definition: sound.h:60
This class is a list of sounds with common playlist features.
Definition: playlist.h:58
Audio::Playlist * MusicPlaylist
A pointer to the active playlist used by this player.
Definition: musicplayer.h:66
#define MEZZ_LIB
Some platforms require special decorations to denote what is exported/imported in a share library...
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
Boole Playing
Stores whether or not this player is currently playing.
Definition: musicplayer.h:75
std::list< Audio::iSound * >::iterator TrackIterator
Convenience type for track iterators from playlists.
Definition: musicplayer.h:62
A base type that provides container features for different tracks.
Definition: track.h:65
Boole EOPShuffle
Stores whether or not the player will shuffle the playlist when it finishes playing all the tracks in...
Definition: musicplayer.h:81
Boole ManualStop
Stores whether or not the current track has been manually stopped.
Definition: musicplayer.h:72