Files
whisper-local/whisper_local/media/__init__.py
T

30 lines
1000 B
Python
Raw Normal View History

"""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 unterstützten Plattformen
wird 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()
if sys.platform == "win32":
from whisper_local.media._smtc import SmtcController
return SmtcController()
from whisper_local.media._noop import NoopController
return NoopController()