It's working more or less...
This commit is contained in:
@ -1,9 +1,61 @@
|
||||
#include "playlist.h"
|
||||
|
||||
Playlist::Playlist(String id) {
|
||||
rfid_id = id;
|
||||
}
|
||||
|
||||
String Playlist::get_rfid_id() {
|
||||
return rfid_id;
|
||||
}
|
||||
|
||||
void Playlist::add_file(String filename) {
|
||||
files.push_back(filename);
|
||||
}
|
||||
|
||||
void Playlist::sort() {
|
||||
std::sort(files.begin(), files.end());
|
||||
}
|
||||
|
||||
void Playlist::set_current_position(uint8_t file, uint32_t seconds) {
|
||||
current_file = file;
|
||||
current_time = seconds;
|
||||
}
|
||||
|
||||
String Playlist::get_current_file_name() {
|
||||
if (current_file >= files.size()) {
|
||||
Serial.printf("Requested a file number %d, which is not available in this playlist. Starting over.\n", current_file);
|
||||
set_current_position(0);
|
||||
}
|
||||
return files[current_file];
|
||||
}
|
||||
|
||||
bool Playlist::next_track() {
|
||||
if (files.size() <= current_file + 1) {
|
||||
Serial.println("next_track does not exist. Resetting playlist and returning false.");
|
||||
set_current_position(0, 0);
|
||||
return false;
|
||||
}
|
||||
set_current_position(current_file + 1, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Playlist::prev_track() {
|
||||
if (current_file == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
set_current_position(current_file - 1, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Playlist::restart() {
|
||||
current_time = 0;
|
||||
}
|
||||
|
||||
void Playlist::set_current_time(uint32_t pos) {
|
||||
current_time = pos;
|
||||
}
|
||||
|
||||
uint32_t Playlist::get_current_time() {
|
||||
return current_time;
|
||||
}
|
Reference in New Issue
Block a user