summaryrefslogtreecommitdiffstats
path: root/mp3player.h
diff options
context:
space:
mode:
authorjdlugosz963 <jdlugosz963@gmail.com>2022-12-22 18:50:33 +0100
committerjdlugosz963 <jdlugosz963@gmail.com>2022-12-22 18:50:33 +0100
commitafe2df4dfa6d6858f5352f55e8e00ba05faf69fa (patch)
tree700861716c349065de1f55938ff0c53c8d7f24d4 /mp3player.h
parent8ac38a78b40eef6c0b9bd770a28332537c339675 (diff)
downloadshack-afe2df4dfa6d6858f5352f55e8e00ba05faf69fa.tar.gz
shack-afe2df4dfa6d6858f5352f55e8e00ba05faf69fa.zip
Add mp3 player
Diffstat (limited to 'mp3player.h')
-rw-r--r--mp3player.h69
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
13enum ListMode {
14 SECTIONS=0,
15 MUSIC_FILES=1
16};
17
18class 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
28public:
29 MP3List(File*, ListMode);
30 ~MP3List();
31 String getCurrent();
32 String getNext();
33 String getPrevious();
34};
35
36
37class 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