feat: add tooltip for progress bar seeking

This commit is contained in:
mmacierzanka committed 2026-08-21 21:12:24 +02:00
1 parent 9e568e0581
commit ca17c742c9
5 files changed
+113 -5

No files matched your search

+8
View File
@@ -51,6 +51,7 @@ class MusicPlayer:
self._states: dict[int, GuildMusicState] = {}
self._playback_tokens: dict[int, int] = {}
self._interrupted_playbacks: set[int] = set()
self._seek_locks: dict[int, asyncio.Lock] = {}
self.on_state_change: StateChangeHook | None = None
# --- Stan ---------------------------------------------------------------
@@ -293,6 +294,13 @@ class MusicPlayer:
await self._restart_playback(guild_id)
async def seek(self, guild_id: int, seconds: float) -> float:
lock = self._seek_locks.setdefault(guild_id, asyncio.Lock())
if lock.locked():
raise RuntimeError("Another seek operation is already in progress")
async with lock:
return await self._seek_locked(guild_id, seconds)
async def _seek_locked(self, guild_id: int, seconds: float) -> float:
state = self.state(guild_id)
current = state.current
voice_client = self.voice_client(guild_id)
@@ -121,6 +121,8 @@ async def seek(
seconds = await player.seek(guild.id, request.seconds)
except ValueError as error:
raise HTTPException(status_code=400, detail=str(error)) from error
except RuntimeError as error:
raise HTTPException(status_code=409, detail=str(error)) from error
await broadcaster.broadcast()
return {"status": "seeked", "seconds": seconds}