fix: keep editor playback active on playhead changes

This commit is contained in:
2026-07-04 21:31:22 +02:00
parent d36c61a6d5
commit 443ba225cd
2 changed files with 54 additions and 5 deletions
+45
View File
@@ -1076,6 +1076,51 @@ def test_editor_play_button_loops_selection_when_playhead_inside(win, tmp_path,
assert seen == {"start": 1.25, "end": 2.75, "loop": True}
def test_editor_playhead_change_keeps_playback_running(win, tmp_path, monkeypatch):
import main as m
src = tmp_path / "v0.wav"; src.write_bytes(b"")
dlg = m.AudioEditorDialog(str(src), parent=win)
dlg._clip_dur = 5.0
dlg._wave.set_view(0.0, 5.0)
dlg._wave.set_selection(1.25, 2.75)
dlg._wave.set_playhead(4.0)
dlg._play_proc = object()
dlg._btn_play.setChecked(True)
seen = {}
stopped = {"n": 0}
monkeypatch.setattr(
dlg, "_play_current",
lambda start=None, end=None, loop=False:
seen.update(start=start, end=end, loop=loop))
monkeypatch.setattr(dlg, "_stop_play", lambda: stopped.__setitem__("n", stopped["n"] + 1))
dlg._on_wave_playhead_changed(4.0)
assert seen == {"start": 4.0, "end": 5.0, "loop": False}
assert stopped["n"] == 0
assert dlg._btn_play.isChecked()
def test_editor_playhead_change_keeps_looping_when_inside_selection(win, tmp_path, monkeypatch):
import main as m
src = tmp_path / "v0.wav"; src.write_bytes(b"")
dlg = m.AudioEditorDialog(str(src), parent=win)
dlg._clip_dur = 5.0
dlg._wave.set_view(0.0, 5.0)
dlg._wave.set_selection(1.25, 2.75)
dlg._wave.set_playhead(2.0)
dlg._play_proc = object()
dlg._btn_play.setChecked(True)
seen = {}
stopped = {"n": 0}
monkeypatch.setattr(
dlg, "_play_current",
lambda start=None, end=None, loop=False:
seen.update(start=start, end=end, loop=loop))
monkeypatch.setattr(dlg, "_stop_play", lambda: stopped.__setitem__("n", stopped["n"] + 1))
dlg._on_wave_playhead_changed(2.0)
assert seen == {"start": 1.25, "end": 2.75, "loop": True}
assert stopped["n"] == 0
def test_editor_has_local_speed_controls(win, tmp_path):
import main as m
from PyQt6.QtWidgets import QPushButton