2019-11-14 19:42:02 +00:00
|
|
|
#pragma once
|
|
|
|
#include <Arduino.h>
|
|
|
|
#include <vector>
|
2019-11-16 22:03:13 +00:00
|
|
|
#include <ArduinoJson.h>
|
2019-11-27 05:51:20 +00:00
|
|
|
#include "http_client_wrapper.h"
|
|
|
|
|
2019-11-29 16:41:16 +00:00
|
|
|
enum PlaylistPersistence {
|
|
|
|
PERSIST_NONE,
|
|
|
|
PERSIST_TEMPORARY,
|
|
|
|
PERSIST_PERMANENTLY
|
|
|
|
};
|
|
|
|
|
2019-11-27 05:51:20 +00:00
|
|
|
struct PlaylistEntry {
|
|
|
|
String filename;
|
|
|
|
String title;
|
2019-11-29 16:41:16 +00:00
|
|
|
String id;
|
2019-11-27 05:51:20 +00:00
|
|
|
|
|
|
|
bool operator<(PlaylistEntry p) { return title < p.title; }
|
|
|
|
};
|
2019-11-14 19:42:02 +00:00
|
|
|
|
|
|
|
class Playlist {
|
|
|
|
private:
|
|
|
|
uint32_t _position = 0;
|
|
|
|
uint32_t _current_track = 0;
|
2019-11-16 22:03:13 +00:00
|
|
|
bool _started = false;
|
2019-11-14 19:42:02 +00:00
|
|
|
bool _shuffled = false;
|
2019-11-27 05:51:20 +00:00
|
|
|
std::vector<PlaylistEntry> _files;
|
2019-11-28 05:20:57 +00:00
|
|
|
String _title = "";
|
2019-11-29 16:41:16 +00:00
|
|
|
String _path;
|
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);
|
2019-11-14 19:42:02 +00:00
|
|
|
public:
|
2019-11-29 16:41:16 +00:00
|
|
|
PlaylistPersistence persistence = PERSIST_TEMPORARY;
|
2019-11-27 05:51:20 +00:00
|
|
|
Playlist(String path);
|
2019-11-16 22:03:13 +00:00
|
|
|
void start();
|
2019-11-27 05:51:20 +00:00
|
|
|
uint16_t get_file_count();
|
2019-11-14 19:42:02 +00:00
|
|
|
bool has_track_next();
|
|
|
|
bool has_track_prev();
|
|
|
|
bool track_next();
|
|
|
|
bool track_prev();
|
|
|
|
void track_restart();
|
2019-11-16 22:03:13 +00:00
|
|
|
bool set_track(uint8_t track);
|
2019-11-29 16:41:16 +00:00
|
|
|
void set_track_by_id(String id);
|
2019-11-14 19:42:02 +00:00
|
|
|
void reset();
|
2019-11-29 16:41:16 +00:00
|
|
|
String path();
|
2019-11-14 19:42:02 +00:00
|
|
|
bool is_empty();
|
2019-11-29 04:52:00 +00:00
|
|
|
bool get_current_file(String* dst);
|
2019-11-29 16:41:16 +00:00
|
|
|
String get_current_track_id();
|
2019-11-14 19:42:02 +00:00
|
|
|
uint32_t get_position();
|
|
|
|
void set_position(uint32_t p);
|
|
|
|
void shuffle(uint8_t random_offset=0);
|
2019-11-16 22:03:13 +00:00
|
|
|
void advent_shuffle(uint8_t day);
|
2019-11-14 19:42:02 +00:00
|
|
|
bool is_fresh();
|
2019-11-16 22:03:13 +00:00
|
|
|
void dump();
|
|
|
|
void json(JsonObject json);
|
2019-11-14 19:42:02 +00:00
|
|
|
};
|