00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef SDLMUSICLIST_H
00023 #define SDLMUSICLIST_H
00024
00025 #include <vector>
00026 #include "SDL/SDL.h"
00027
00028 using namespace std;
00029
00030 class SdlMusic;
00031 class SdlAudio;
00032
00049 class DECLSPEC SdlMusicInfo
00050 {
00051 public:
00060 DECLSPEC SdlMusicInfo( const char *fn, const char *title, const char *author, int secs = -1 );
00061 virtual DECLSPEC ~SdlMusicInfo();
00062
00067 DECLSPEC void setFileName( const char *n );
00069 const char * getFileName() { return chName; }
00070
00075 DECLSPEC void setTitle( const char *t );
00077 const char * getTitle() { return chTitle; }
00078
00083 DECLSPEC void setAuthor( const char *a );
00085 const char * getAuthor() { return chAuthor; }
00086
00091 void setLength( int l ) { nLength = l; }
00092
00094 int numPlayed() { return nPlayed; }
00099 void played() { ++nPlayed; }
00103 void reset() { nPlayed = 0; }
00104
00105 private:
00106 char *chName;
00107 char *chTitle;
00108 char *chAuthor;
00109 int nPlayed;
00110 int nLength;
00111 };
00112
00113
00114
00129 class SdlMusicList
00130 {
00131 public:
00139 typedef void ( *CallBack )( SdlMusicList *, void * );
00147 enum PlayTypes{ptForward, ptBackward, ptShuffled, ptRandom};
00148
00153 DECLSPEC SdlMusicList( const char *name );
00154 virtual DECLSPEC ~SdlMusicList();
00155
00157 const char *getName() const { return chName; }
00163 DECLSPEC SdlMusic *getSong( unsigned int i );
00169 DECLSPEC SdlMusicInfo *getSongInfo( unsigned int i );
00171 unsigned int numSongs() { return lSongs.size(); }
00172
00179 DECLSPEC bool play( PlayTypes t = ptForward );
00181 DECLSPEC void stop();
00182
00188 DECLSPEC void setVolume( int v );
00189
00197 void setCallBack( CallBack c, void *data ) { cb = c; cbData = data; }
00198
00203 bool isFailed() { return bFailed; }
00204
00205 protected:
00207 virtual DECLSPEC void failed();
00208
00210 vector<SdlMusic *> lSongs;
00212 vector<SdlMusicInfo*> lInfos;
00213
00214 private:
00215 bool playNext();
00216
00217 bool bFailed;
00218 char *chName;
00219
00220 PlayTypes ePlayType;
00221 bool bStopped;
00222
00223 int nVolume;
00224
00225 CallBack cb;
00226 void *cbData;
00227
00228 int nCurrentSong;
00229 SdlMusic *musPlaying;
00230 static inline void onFinished( SdlAudio *sender, void *data )
00231 {
00232 ((SdlMusicList*)data)->playNext();
00233 }
00234 };
00235
00236 #endif