From 7a998f230c183544f48dc52674a29d23343550c4 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Tue, 17 Dec 2024 01:34:01 +0100 Subject: [PATCH] Identify "playing" entry in playlist by playlist.idx rather than digest, to avoid entries of same file claiming to be "playing" in parallel. --- src/templates/playlist.tmpl | 2 +- src/ytplom/http.py | 2 +- src/ytplom/misc.py | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/templates/playlist.tmpl b/src/templates/playlist.tmpl index eed3d1e..ad5c18b 100644 --- a/src/templates/playlist.tmpl +++ b/src/templates/playlist.tmpl @@ -23,7 +23,7 @@ event_handlers.push(function(data) { // update playlist tr.classList.add(CLS_PLAYLIST_ROW); const td_entry_control = new_child_to('td', tr); td_entry_control.classList.add('entry_control'); - if (data.title_digest == file.digest) { + if (i == data.idx) { td_entry_control.textContent = 'playing'; } else { for (const [symbol, prefix] of [['>', 'jump'], diff --git a/src/ytplom/http.py b/src/ytplom/http.py index 165e5eb..6ccf282 100644 --- a/src/ytplom/http.py +++ b/src/ytplom/http.py @@ -410,7 +410,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': digest, + 'idx': self.server.player.idx, 'title_tags': tags, 'title': title} if 'playlist' in params.as_dict: diff --git a/src/ytplom/misc.py b/src/ytplom/misc.py index 81406d0..3671779 100644 --- a/src/ytplom/misc.py +++ b/src/ytplom/misc.py @@ -620,6 +620,11 @@ class Player: self._kill_mpv() self._start_mpv() + @property + def idx(self) -> int: + """Read-only access to ._idx.""" + return self._idx + @property def empty(self) -> bool: """Return if playlist empty.""" -- 2.30.2