Skip to content

Commit 6463df7

Browse files
committed
More timer-resets, refactor _play
1 parent 7878598 commit 6463df7

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

BoxPlayer.cpp

+12-3
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@ void BoxPlayer::loop() {
1616
void BoxPlayer::play() {
1717
Log.info("Player play");
1818
Box.boxDAC.play();
19+
Box.boxPower.feedSleepTimer();
1920
}
2021
void BoxPlayer::pause() {
2122
Log.info("Player pause");
2223
Box.boxDAC.pause();
24+
Box.boxPower.feedSleepTimer();
2325
}
2426
void BoxPlayer::stop() {
2527
Log.info("Player stop");
2628
Box.boxDAC.stop();
29+
Box.boxPower.feedSleepTimer();
2730
}
2831
void BoxPlayer::rewind() {
2932
//TODO
@@ -64,13 +67,18 @@ void BoxPlayer::songEnded() {
6467
}
6568
dir.closeDir();
6669
if (songIndex > 0)
67-
Box.boxDAC.playFile(songPath);
70+
_play(songPath);
6871
} else {
6972
Log.error("Player could not open dir %s...", _dirPath);
7073
}
7174
}
7275
}
7376

77+
bool BoxPlayer::_play(const char* path) {
78+
Box.boxPower.feedSleepTimer();
79+
return Box.boxDAC.playFile(path);
80+
}
81+
7482
bool BoxPlayer::playDir(const char* path, PLAYER_FLAGS flags) {
7583
Log.info("Playing dir %s", _dirPath);
7684

@@ -94,7 +102,7 @@ bool BoxPlayer::playDir(const char* path, PLAYER_FLAGS flags) {
94102
}
95103
dir.closeDir();
96104
if (_dirSongCount > 0) {
97-
return Box.boxDAC.playFile(songPath);
105+
return _play(songPath);
98106
} else {
99107
Log.error("Player could not find songs to play...");
100108
}
@@ -106,7 +114,8 @@ bool BoxPlayer::playDir(const char* path, PLAYER_FLAGS flags) {
106114
bool BoxPlayer::playFile(const char* file, PLAYER_FLAGS flags) {
107115
_mode = PLAYER_MODE::FILE;
108116
_flags = flags;
109-
return Box.boxDAC.playFile(file);
117+
Log.info("Playing file %s", file);
118+
return _play(file);
110119
}
111120

112121
bool BoxPlayer::isPlaying() {

BoxPlayer.h

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class BoxPlayer {
4646
uint8_t _currentSongId;
4747
uint8_t _dirSongCount;
4848

49+
bool _play(const char* path);
50+
4951
};
5052

5153
#endif

0 commit comments

Comments
 (0)