From 265ca3c212c120c53da33235f53768668cf93a6f Mon Sep 17 00:00:00 2001 From: Vitali Graf Date: Thu, 16 Apr 2026 18:16:51 +0200 Subject: [PATCH] feat(media): Factory dispatcht auf win32 zum SmtcController --- tests/test_media_factory.py | 12 ++++++++++-- whisper_local/media/__init__.py | 7 +++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/tests/test_media_factory.py b/tests/test_media_factory.py index b3965ec..6cbb38f 100644 --- a/tests/test_media_factory.py +++ b/tests/test_media_factory.py @@ -14,8 +14,8 @@ def test_factory_returns_noop_when_disabled(): assert isinstance(controller, NoopController) -def test_factory_returns_noop_on_non_linux(): - with patch.object(sys, "platform", "win32"): +def test_factory_returns_noop_on_other_platforms(): + with patch.object(sys, "platform", "darwin"): controller = create_media_controller(enabled=True) assert isinstance(controller, NoopController) @@ -38,3 +38,11 @@ async def test_noop_controller_pause_is_noop(): def test_noop_controller_satisfies_protocol(): controller = NoopController() assert isinstance(controller, MediaController) + + +@pytest.mark.skipif(sys.platform != "win32", reason="SmtcController nur auf Windows") +def test_factory_returns_smtc_on_win32_when_enabled(): + from whisper_local.media._smtc import SmtcController + + controller = create_media_controller(enabled=True) + assert isinstance(controller, SmtcController) diff --git a/whisper_local/media/__init__.py b/whisper_local/media/__init__.py index 90bf3d0..e7620fb 100644 --- a/whisper_local/media/__init__.py +++ b/whisper_local/media/__init__.py @@ -13,8 +13,8 @@ class MediaController(Protocol): def create_media_controller(enabled: bool) -> MediaController: """Erstellt den plattformspezifischen Media-Controller. - `enabled=False` → immer NoopController. Auf Nicht-Linux-Plattformen - wird aktuell ebenfalls der NoopController zurückgegeben. + `enabled=False` → immer NoopController. Auf nicht unterstützten Plattformen + wird ebenfalls der NoopController zurückgegeben. """ if not enabled: from whisper_local.media._noop import NoopController @@ -22,5 +22,8 @@ def create_media_controller(enabled: bool) -> MediaController: if sys.platform == "linux": from whisper_local.media._mpris import MprisController return MprisController() + if sys.platform == "win32": + from whisper_local.media._smtc import SmtcController + return SmtcController() from whisper_local.media._noop import NoopController return NoopController()