esmp3/include/playlist.h

48 lines
1.1 KiB
C
Raw Permalink Normal View History

#pragma once
#include <Arduino.h>
#include <vector>
#include <ArduinoJson.h>
2019-11-27 05:51:20 +00:00
#include "http_client_wrapper.h"
struct PlaylistEntry {
String filename;
String title;
bool operator<(PlaylistEntry p) { return title < p.title; }
};
class Playlist {
private:
uint32_t _position = 0;
uint32_t _current_track = 0;
bool _started = false;
bool _shuffled = false;
2019-11-27 05:51:20 +00:00
std::vector<PlaylistEntry> _files;
String _title = "";
2019-11-27 05:51:20 +00:00
void _add_path(String path);
void _examine_http_url(String url);
void _parse_rss(HTTPClientWrapper* http);
void _parse_m3u(HTTPClientWrapper* http);
void _parse_pls(HTTPClientWrapper* http);
public:
2019-11-27 05:51:20 +00:00
Playlist(String path);
void start();
2019-11-27 05:51:20 +00:00
uint16_t get_file_count();
bool has_track_next();
bool has_track_prev();
bool track_next();
bool track_prev();
void track_restart();
bool set_track(uint8_t track);
void reset();
bool is_empty();
String get_current_file();
uint32_t get_position();
void set_position(uint32_t p);
void shuffle(uint8_t random_offset=0);
void advent_shuffle(uint8_t day);
bool is_fresh();
void dump();
void json(JsonObject json);
};