feat(media): Protocol, Factory und Noop-Controller
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
"""Media-Steuerung — plattformspezifische Backends hinter gemeinsamem Interface."""
|
||||
|
||||
import sys
|
||||
from typing import Protocol, runtime_checkable
|
||||
|
||||
|
||||
@runtime_checkable
|
||||
class MediaController(Protocol):
|
||||
async def pause(self) -> None: ...
|
||||
async def resume(self) -> None: ...
|
||||
|
||||
|
||||
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.
|
||||
"""
|
||||
if not enabled:
|
||||
from whisper_local.media._noop import NoopController
|
||||
return NoopController()
|
||||
if sys.platform == "linux":
|
||||
from whisper_local.media._mpris import MprisController
|
||||
return MprisController()
|
||||
from whisper_local.media._noop import NoopController
|
||||
return NoopController()
|
||||
Reference in New Issue
Block a user