feat: add playback seeking
Backend / Lint i formatowanie (pull_request) Successful in 4s
Backend / Testy i kontrakt API (pull_request) Successful in 4s
Backend / Testowy build obrazu (pull_request) Successful in 11s
Panel / Lint, typy i build (pull_request) Successful in 21s

This commit is contained in:
mmacierzanka committed 2026-08-21 18:53:38 +02:00
1 parent ed13d4af06
commit 7ef0a43693
12 files changed
+170 -8

No files matched your search

+3 -1
View File
@@ -59,9 +59,11 @@ def build_player(default_plays: int = 5) -> tuple[MusicPlayer, FakeVoiceClient]:
bot.loop = asyncio.get_event_loop()
voice_client = FakeVoiceClient()
async def recreate(track, loop=None):
async def recreate(track, loop=None, start_at=0.0):
fresh = FakeTrack(track.id)
fresh.plays_left = track.plays_left
fresh.duration = track.duration
fresh.elapsed = start_at
return fresh
tracks = MagicMock()
+1
View File
@@ -15,6 +15,7 @@ EXPECTED_ENDPOINTS = {
("post", "/api/play_file"),
("post", "/api/pause"),
("post", "/api/resume"),
("post", "/api/seek"),
("post", "/api/skip"),
("post", "/api/stop"),
("post", "/api/volume"),
+10
View File
@@ -103,6 +103,16 @@ class MusicPlayerQueueTest(unittest.IsolatedAsyncioTestCase):
self.assertEqual(state.current.id, "b")
self.assertEqual(state.queue[0].plays_left, 4)
async def test_seek_restarts_current_track_at_requested_position(self):
player, voice_client, state = await self._queue_abc()
position = await player.seek(GUILD, 4.5)
self.assertEqual(position, 4.5)
self.assertEqual(state.current.id, "a")
self.assertEqual(state.current.elapsed, 4.5)
self.assertIs(voice_client.playing, state.current)
async def test_loop_track_replays_same_index(self):
player, _, state = await self._queue_abc()
await player.play_next(GUILD, advance=True)