You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
add playFile() blocking method for audio playback (#2048)
summary:
adds a new `playFile(const char *filePath)` method to the `AudioPlayer` class that provides a simple blocking way to play a complete audio file from start to finish.
- new method: `bool playFile(const char *filePath)` in the public section of `AudioPlayer` class
- functionality:
- sets the audio file path using existing `setPath()` method
- starts playback with `play()`
- blocks execution until the entire file finishes playing
- automatically stops when no more audio data is available
- returns `true` on success, `false` if file cannot be opened
use case:
i used this library for an ESP32 project at school and needed a blocking method to do nothing BUT play a specific audio file before continuing the program, so i made my own and thought other people might need it!
example usage:
```cpp
AudioPlayer player(source, output, decoder);
...
setup() {
player.begin();
}
...
loop() {
// play a complete file (blocking)
if (player.playFile("/song1.mp3")) {
// file plays successfully
} else {
// file not found or other error occurred
}
doSomething();
}
```
this addition shouldn't affect any existing functionality!
0 commit comments