Compare commits
4 Commits
6f8683ba9d
...
8f19b990ff
Author | SHA1 | Date | |
---|---|---|---|
8f19b990ff | |||
519ac0e3bd | |||
651843fb06 | |||
fcbbdce118 |
@ -203,12 +203,10 @@ update_playlist = function(data) {
|
|||||||
$('#button_track_prev').removeClass('btn-primary').addClass('btn-secondary', 'btn-disabled');
|
$('#button_track_prev').removeClass('btn-primary').addClass('btn-secondary', 'btn-disabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$('#album').html(data.title);
|
||||||
var file = data.files[data.current_track];
|
var file = data.files[data.current_track];
|
||||||
if (file) {
|
if (file) {
|
||||||
file = file.substr(1);
|
$('#track').html(file.title);
|
||||||
$('#album').html(file.substr(0, file.indexOf('/')));
|
|
||||||
file = file.substr(file.indexOf('/')+1);
|
|
||||||
$('#track').html(file.substr(0, file.lastIndexOf('.')));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,13 +18,13 @@ private:
|
|||||||
bool _started = false;
|
bool _started = false;
|
||||||
bool _shuffled = false;
|
bool _shuffled = false;
|
||||||
std::vector<PlaylistEntry> _files;
|
std::vector<PlaylistEntry> _files;
|
||||||
|
String _title = "";
|
||||||
void _add_path(String path);
|
void _add_path(String path);
|
||||||
void _examine_http_url(String url);
|
void _examine_http_url(String url);
|
||||||
void _parse_rss(HTTPClientWrapper* http);
|
void _parse_rss(HTTPClientWrapper* http);
|
||||||
void _parse_m3u(HTTPClientWrapper* http);
|
void _parse_m3u(HTTPClientWrapper* http);
|
||||||
void _parse_pls(HTTPClientWrapper* http);
|
void _parse_pls(HTTPClientWrapper* http);
|
||||||
public:
|
public:
|
||||||
String title;
|
|
||||||
Playlist(String path);
|
Playlist(String path);
|
||||||
void start();
|
void start();
|
||||||
uint16_t get_file_count();
|
uint16_t get_file_count();
|
||||||
|
@ -12,6 +12,7 @@ Playlist::Playlist(String path) {
|
|||||||
} else if (path.startsWith("http")) {
|
} else if (path.startsWith("http")) {
|
||||||
_examine_http_url(path);
|
_examine_http_url(path);
|
||||||
}
|
}
|
||||||
|
if (_title.length()==0) _title=path;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Playlist::_add_path(String path) {
|
void Playlist::_add_path(String path) {
|
||||||
@ -23,6 +24,11 @@ void Playlist::_add_path(String path) {
|
|||||||
SPIMaster::select_sd(false);
|
SPIMaster::select_sd(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
_title = path.substring(1);
|
||||||
|
int idx = _title.indexOf('/');
|
||||||
|
if (idx>0) {
|
||||||
|
_title.remove(idx);
|
||||||
|
}
|
||||||
File dir = SD.open(path);
|
File dir = SD.open(path);
|
||||||
File entry;
|
File entry;
|
||||||
while (entry = dir.openNextFile()) {
|
while (entry = dir.openNextFile()) {
|
||||||
@ -38,7 +44,7 @@ void Playlist::_add_path(String path) {
|
|||||||
ext.equals(".mpa"))) {
|
ext.equals(".mpa"))) {
|
||||||
TRACE(" Adding entry %s\n", entry.name());
|
TRACE(" Adding entry %s\n", entry.name());
|
||||||
String title = filename.substring(0, filename.length() - 4);
|
String title = filename.substring(0, filename.length() - 4);
|
||||||
_files.push_back({entry.name(), title});
|
_files.push_back({.filename=entry.name(), .title=title});
|
||||||
bool non_ascii_chars = false;
|
bool non_ascii_chars = false;
|
||||||
for(int i=0; i<filename.length(); i++) {
|
for(int i=0; i<filename.length(); i++) {
|
||||||
char c = filename.charAt(i);
|
char c = filename.charAt(i);
|
||||||
@ -71,7 +77,7 @@ void Playlist::_examine_http_url(String url) {
|
|||||||
if (ct.startsWith("audio/x-mpegurl")) {
|
if (ct.startsWith("audio/x-mpegurl")) {
|
||||||
_parse_m3u(http);
|
_parse_m3u(http);
|
||||||
} else if (ct.startsWith("audio/")) {
|
} else if (ct.startsWith("audio/")) {
|
||||||
_files.push_back({url, url});
|
_files.push_back({.filename=url, .title=url});
|
||||||
} else if (ct.startsWith("application/rss+xml")) {
|
} else if (ct.startsWith("application/rss+xml")) {
|
||||||
_parse_rss(http);
|
_parse_rss(http);
|
||||||
} else if (ct.startsWith("application/pls+xml")) {
|
} else if (ct.startsWith("application/pls+xml")) {
|
||||||
@ -144,7 +150,7 @@ void Playlist::_parse_rss(HTTPClientWrapper* http) {
|
|||||||
}
|
}
|
||||||
xml_files_ptr = NULL;
|
xml_files_ptr = NULL;
|
||||||
if (xml_album_title.length()>0) {
|
if (xml_album_title.length()>0) {
|
||||||
title = xml_album_title;
|
_title = xml_album_title;
|
||||||
}
|
}
|
||||||
xml_album_title = "";
|
xml_album_title = "";
|
||||||
delete buffer;
|
delete buffer;
|
||||||
@ -170,10 +176,11 @@ void Playlist::_parse_m3u(HTTPClientWrapper* http) {
|
|||||||
if (idx>4) {
|
if (idx>4) {
|
||||||
// Get the title
|
// Get the title
|
||||||
title = line.substring(idx+1);
|
title = line.substring(idx+1);
|
||||||
|
if (_title.length()==0) _title=title;
|
||||||
}
|
}
|
||||||
} else if (line.startsWith("http")) {
|
} else if (line.startsWith("http")) {
|
||||||
if (title.length()==0) title = line;
|
if (title.length()==0) title = line;
|
||||||
_files.push_back({line, title});
|
_files.push_back({.filename=line, .title=title});
|
||||||
title = "";
|
title = "";
|
||||||
}
|
}
|
||||||
line = "";
|
line = "";
|
||||||
@ -215,7 +222,7 @@ void Playlist::_parse_pls(HTTPClientWrapper* http) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (title.length()>0 && url.length()>0) {
|
if (title.length()>0 && url.length()>0) {
|
||||||
_files.push_back({url, title});
|
_files.push_back({.filename=url, .title=title});
|
||||||
last_index = -1;
|
last_index = -1;
|
||||||
title = "";
|
title = "";
|
||||||
url = "";
|
url = "";
|
||||||
@ -327,6 +334,7 @@ void Playlist::dump() {
|
|||||||
|
|
||||||
void Playlist::json(JsonObject json) {
|
void Playlist::json(JsonObject json) {
|
||||||
json["_type"] = "playlist";
|
json["_type"] = "playlist";
|
||||||
|
json["title"] = _title;
|
||||||
JsonArray files = json.createNestedArray("files");
|
JsonArray files = json.createNestedArray("files");
|
||||||
for (PlaylistEntry entry: _files) {
|
for (PlaylistEntry entry: _files) {
|
||||||
JsonObject o = files.createNestedObject();
|
JsonObject o = files.createNestedObject();
|
||||||
|
@ -40,15 +40,17 @@ void PlaylistManager::scan_files() {
|
|||||||
TRACE(" Adding mapping: %s=>%s\n", rfid_id.c_str(), folder.c_str());
|
TRACE(" Adding mapping: %s=>%s\n", rfid_id.c_str(), folder.c_str());
|
||||||
_map[rfid_id] = folder;
|
_map[rfid_id] = folder;
|
||||||
|
|
||||||
bool found=false;
|
if (folder.charAt(0)=='/') {
|
||||||
for (String f: folders) {
|
bool found=false;
|
||||||
if (f.equals(folder)) {
|
for (String f: folders) {
|
||||||
found = true;
|
if (f.equals(folder)) {
|
||||||
break;
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
INFO("WARNING: Found mapping for RFID id %s which maps to non-existing folder %s!\n", rfid_id.c_str(), folder.c_str());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!found) {
|
|
||||||
INFO("WARNING: Found mapping for RFID id %s which maps to non-existing folder %s!\n", rfid_id.c_str(), folder.c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user