diff --git a/data/index.html b/data/index.html
index fbbb882..8b1c53f 100644
--- a/data/index.html
+++ b/data/index.html
@@ -203,10 +203,9 @@ update_playlist = function(data) {
$('#button_track_prev').removeClass('btn-primary').addClass('btn-secondary', 'btn-disabled');
}
+ $('#album').html(data.title);
var file = data.files[data.current_track];
if (file) {
- file = file.substr(1);
- $('#album').html(file.substr(0, file.indexOf('/')));
$('#track').html(file.title);
}
}
diff --git a/include/playlist.h b/include/playlist.h
index 89a69b2..0da83e6 100644
--- a/include/playlist.h
+++ b/include/playlist.h
@@ -18,13 +18,13 @@ private:
bool _started = false;
bool _shuffled = false;
std::vector _files;
+ String _title = "";
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:
- String title;
Playlist(String path);
void start();
uint16_t get_file_count();
diff --git a/src/playlist.cpp b/src/playlist.cpp
index 052d395..1dd7516 100644
--- a/src/playlist.cpp
+++ b/src/playlist.cpp
@@ -12,6 +12,7 @@ Playlist::Playlist(String path) {
} else if (path.startsWith("http")) {
_examine_http_url(path);
}
+ if (_title.length()==0) _title=path;
}
void Playlist::_add_path(String path) {
@@ -23,6 +24,11 @@ void Playlist::_add_path(String path) {
SPIMaster::select_sd(false);
return;
}
+ _title = path.substring(1);
+ int idx = _title.indexOf('/');
+ if (idx>0) {
+ _title.remove(idx);
+ }
File dir = SD.open(path);
File entry;
while (entry = dir.openNextFile()) {
@@ -144,7 +150,7 @@ void Playlist::_parse_rss(HTTPClientWrapper* http) {
}
xml_files_ptr = NULL;
if (xml_album_title.length()>0) {
- title = xml_album_title;
+ _title = xml_album_title;
}
xml_album_title = "";
delete buffer;
@@ -170,6 +176,7 @@ void Playlist::_parse_m3u(HTTPClientWrapper* http) {
if (idx>4) {
// Get the title
title = line.substring(idx+1);
+ if (_title.length()==0) _title=title;
}
} else if (line.startsWith("http")) {
if (title.length()==0) title = line;
@@ -327,6 +334,7 @@ void Playlist::dump() {
void Playlist::json(JsonObject json) {
json["_type"] = "playlist";
+ json["title"] = _title;
JsonArray files = json.createNestedArray("files");
for (PlaylistEntry entry: _files) {
JsonObject o = files.createNestedObject();