v0.5.2: custom start times survive a track change

Playing a track with an iTunes start time (e.g. "Pretty Girls is a
Motherfucker", 0:40) began at 0:00 whenever another track was already
loaded. QMediaPlayer.setSource() synchronously emits two status changes
before returning: a LoadedMedia still reporting the *outgoing* source,
then LoadingMedia for the new one. The stale first event consumed the
one-shot _pending_start_ms armed in Round 22 and seeked the dying
pipeline, so the new track's real LoadedMedia ~5 ms later found nothing
armed. Only the first track after launch worked.

The armed seek now carries the URL it belongs to and is consumed only
when source() matches. tests/test_round32.py models the real Qt event
sequence, which Round 22's plain MagicMock never emitted; the
test_round8/test_round22 stubs now report the new source by the time its
LoadedMedia arrives, as Qt does.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-14 09:28:50 -04:00
co-authored by Claude Opus 5
parent bcc17a7542
commit 01996d5fe2
6 changed files with 227 additions and 7 deletions
+5
View File
@@ -10,6 +10,8 @@
from unittest.mock import MagicMock, patch
from PyQt6.QtCore import QUrl
from lintunes.models import Library, Track, Playlist, PlaylistType
from lintunes.library_manager import LibraryManager
from lintunes.gui.library_view import _matches_search
@@ -249,6 +251,9 @@ class TestPlayerStartStop:
player, _ = self._player(qapp, [track])
player.play_queue([1], 0)
assert player._local._pending_start_ms == 30_000
# By the time the real LoadedMedia arrives Qt reports the new source;
# since Round 32 the armed seek is only consumed when it matches.
player._local._media.source.return_value = QUrl.fromLocalFile(track.location)
player._local._on_media_status(player_module.QMediaPlayer.MediaStatus.LoadedMedia)
player._local._media.setPosition.assert_called_with(30_000)
assert player._local._pending_start_ms == 0 # consumed (one-shot)