diff options
Diffstat (limited to 'mp3player.h')
-rw-r--r-- | mp3player.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/mp3player.h b/mp3player.h new file mode 100644 index 0000000..c5efabb --- /dev/null +++ b/mp3player.h | |||
@@ -0,0 +1,69 @@ | |||
1 | #ifndef MP3_PLAYER_H | ||
2 | #define MP3_PLAYER_H | ||
3 | |||
4 | #include "AudioOutputI2SNoDAC.h" | ||
5 | #include "AudioGeneratorMP3.h" | ||
6 | #include "AudioFileSourceSD.h" | ||
7 | #include "AudioLogger.h" | ||
8 | #include "controller.h" | ||
9 | #include "SD.h" | ||
10 | #include <iostream> | ||
11 | |||
12 | |||
13 | enum ListMode { | ||
14 | SECTIONS=0, | ||
15 | MUSIC_FILES=1 | ||
16 | }; | ||
17 | |||
18 | class MP3List { | ||
19 | String *list; | ||
20 | int listSize = 0; | ||
21 | int listCurrentPosition = 0; | ||
22 | int countListElements(File*); | ||
23 | void insertElementsToList(File*); | ||
24 | bool canAdd(File*); | ||
25 | void debug(); | ||
26 | ListMode mode; | ||
27 | |||
28 | public: | ||
29 | MP3List(File*, ListMode); | ||
30 | ~MP3List(); | ||
31 | String getCurrent(); | ||
32 | String getNext(); | ||
33 | String getPrevious(); | ||
34 | }; | ||
35 | |||
36 | |||
37 | class MP3Player : public MP3Controller { | ||
38 | AudioFileSourceSD *source; | ||
39 | AudioGeneratorMP3 *mp3; | ||
40 | AudioOutputI2SNoDAC *out; | ||
41 | |||
42 | MP3List *listMusicFiles; | ||
43 | MP3List *listSections; | ||
44 | |||
45 | String currentFolder; | ||
46 | float volume=2.0; | ||
47 | float const volumeBy = 0.3; | ||
48 | |||
49 | String rootDir = "/"; | ||
50 | |||
51 | void playMP3(String); | ||
52 | bool updateListSections(); | ||
53 | bool updateListMusicFiles(); | ||
54 | String getFilePath(String); | ||
55 | |||
56 | |||
57 | public: | ||
58 | MP3Player(); | ||
59 | ~MP3Player(); | ||
60 | void volumeUp(); | ||
61 | void volumeDown(); | ||
62 | void nextSection() override; | ||
63 | void previousSection() override; | ||
64 | void nextFile() override; | ||
65 | void previousFile() override; | ||
66 | void loop(); | ||
67 | }; | ||
68 | |||
69 | #endif | ||