home · contact · privacy
In all-pages player control, link playing title to file page.
authorChristian Heller <c.heller@plomlompom.de>
Tue, 10 Dec 2024 15:57:51 +0000 (16:57 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Tue, 10 Dec 2024 15:57:51 +0000 (16:57 +0100)
src/templates/_base.tmpl
src/ytplom/http.py

index 9f19af61e53f7f6f8b3f9853af68b18c00378674..2161f8f79d4dd514c35d567269bdf5e0262335a9 100644 (file)
@@ -8,6 +8,8 @@
 const RETRY_INTERVAL_S = 5;
 const PATH_EVENTS = '/{{page_names.events}}';
 const PATH_PLAYER = '/{{page_names.player}}';
+const PATH_PLAYLIST = '/{{page_names.playlist}}';
+const PATH_PREFIX_FILE = '/{{page_names.file}}/';
 var event_handlers = [];
 var events_params = '';
 
@@ -42,11 +44,12 @@ function player_command(command) {
     send_to({command: [command]}, PATH_PLAYER); }
 
 event_handlers.push(function(data) {  // update player state
-    const state_desc = data.running ? (data.paused ? 'paused' : 'playing') : 'stopped';
-    for (const [id, text] of [['player_state', `${state_desc}: ${data.title}`],
+    for (const [id, text] of [['player_state', data.running ? (data.paused ? 'paused' : 'playing') : 'stopped'],
+                              ['a_playing', data.title],
                               ['btn_pause', data.paused ? 'resume' : 'pause'],
-                              ['btn_stop', data.running? 'stop' : 'play']]) {
-        document.getElementById(id).textContent = text; }});
+                              ['btn_stop', data.running ? 'stop' : 'play']]) {
+        document.getElementById(id).textContent = text; }
+    document.getElementById('a_playing').href = data.title_digest ? `${PATH_PREFIX_FILE}${data.title_digest}` : PATH_PLAYLIST ; })
 
 {% block script %}
 {% endblock %}
@@ -65,11 +68,12 @@ td, th { vertical-align: top; text-align: left; }
 {{ macros.link_if("playlist" != selected, page_names.playlist) }}
 · {{ macros.link_if("files" != selected, page_names.files) }}
 · {{ macros.link_if("yt_queries" != selected, page_names.yt_queries, "queries") }}
-| <button onclick="player_command('prev')">prev</button>
+<hr />
+<button onclick="player_command('prev')">prev</button>
 <button onclick="player_command('next')">next</button>
-<button id="btn_pause" onclick="player_command('pause')">?</button>
-<button id="btn_stop" onclick="player_command('stop')">?</button>
-<span id="player_state" /></span>
+<button id="btn_pause" onclick="player_command('pause')"></button>
+<button id="btn_stop" onclick="player_command('stop')"></button>
+· <span id="player_state" /></span>: <a id="a_playing"></a>
 <hr />
 {% block body %}
 {% endblock %}
index 90c3ef0c395147e5d74de578ca2926d8479984ad..4535361e1aa74ab0736f9e6992e4c83a963a0a97 100644 (file)
@@ -381,6 +381,7 @@ class _TaskHandler(BaseHTTPRequestHandler):
                     'last_update': self.server.player.last_update,
                     'running': self.server.player.is_running,
                     'paused': self.server.player.is_paused,
+                    'title_digest': playing.digest.b64 if playing else '',
                     'title': str(playing.rel_path) if playing else 'none'}
                 if 'playlist' in params.as_dict:
                     data['playlist_files'] = [