summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2026-02-03 00:26:29 +0100
committerCarl Hetherington <cth@carlh.net>2026-02-03 21:37:04 +0100
commit1242d8e66e0c5baabade775861823fd054b34b92 (patch)
tree16aa55b35d90b902a01fb23d3454a5b6f9c4cb07
parentabfbd4d2b4b9a9a9cc8b566db5e4377030823592 (diff)
Support current playlist in the web interface.
-rw-r--r--src/lib/http_server.cc7
-rw-r--r--src/lib/http_server.h6
-rw-r--r--src/wx/player_frame.cc6
-rw-r--r--web/index.html15
4 files changed, 34 insertions, 0 deletions
diff --git a/src/lib/http_server.cc b/src/lib/http_server.cc
index 43b4cbb84..83ad2551c 100644
--- a/src/lib/http_server.cc
+++ b/src/lib/http_server.cc
@@ -134,6 +134,13 @@ HTTPServer::get_request(string const& url)
json.push_back(spl.second.as_json());
}
return Response(200, json.dump(), Response::Type::JSON);
+ } else if (url == "/api/v1/current-playlist") {
+ nlohmann::json json;
+ boost::mutex::scoped_lock lm(_mutex);
+ for (auto entry: _current_playlist) {
+ json.push_back(entry);
+ }
+ return Response(200, json.dump(), Response::Type::JSON);
} else if (boost::algorithm::starts_with(url, "/api/v1/content/")) {
vector<string> parts;
boost::algorithm::split(parts, url, boost::is_any_of("/"));
diff --git a/src/lib/http_server.h b/src/lib/http_server.h
index 7ca5fa534..42307b124 100644
--- a/src/lib/http_server.h
+++ b/src/lib/http_server.h
@@ -82,6 +82,11 @@ public:
_dcp_name = name;
}
+ void set_current_playlist(std::vector<std::string> playlist) {
+ boost::mutex::scoped_lock lm(_mutex);
+ _current_playlist = playlist;
+ }
+
private:
void handle(std::shared_ptr<Socket> socket) override;
Response request(std::vector<std::string> const& request, std::string const& body);
@@ -93,5 +98,6 @@ private:
bool _playing = false;
dcpomatic::DCPTime _position;
std::string _dcp_name;
+ std::vector<std::string> _current_playlist;
};
diff --git a/src/wx/player_frame.cc b/src/wx/player_frame.cc
index 5097c5e00..565e50ad7 100644
--- a/src/wx/player_frame.cc
+++ b/src/wx/player_frame.cc
@@ -563,6 +563,12 @@ PlayerFrame::idle()
_http_server->set_dcp_name("");
}
_http_server->set_position(_viewer.position());
+ vector<string> names;
+ for (auto const& entry: _playlist) {
+ ShowPlaylistEntry e(entry.first, {});
+ names.push_back(e.name());
+ }
+ _http_server->set_current_playlist(names);
_last_http_server_update = now;
}
}
diff --git a/web/index.html b/web/index.html
index 91e3e0bf1..8a078f7ef 100644
--- a/web/index.html
+++ b/web/index.html
@@ -16,6 +16,21 @@ setInterval(function() {
document.getElementById('position').innerHTML = data.position;
});
});
+ current_playlist = fetch("/api/v1/current-playlist").then(response => {
+ response.json().then(data => {
+ var div = document.getElementById('current-playlist');
+ if (div && data) {
+ div.innerHTML = "";
+ var ul = document.createElement("ul");
+ var list = div.appendChild(ul);
+ data.forEach(entry => {
+ var li = document.createElement("li");
+ li.appendChild(document.createTextNode(entry));
+ list.appendChild(li);
+ });
+ }
+ });
+ });
}, 250);
function play() {
entries = [];