ddf4a6cb29
- Add `linux` (dbus-python, PyGObject, python-xlib) and `macos`
(pyobjc) extras to pyproject.toml with sys_platform markers; move
cross-platform screen-brightness-control + monitorcontrol to base deps.
- build-dist-linux.sh: install `.[linux]`, pkg-config pre-flight for
dbus-1/glib-2.0, emit a systemd unit with DBUS_SESSION_BUS_ADDRESS +
XDG_RUNTIME_DIR + ReadWritePaths for ~/.config and ~/.cache so MPRIS
works and audit-log / thumbnail writes aren't blocked by ProtectHome.
- New build-dist-macos.sh + per-user LaunchAgent installer producing
MediaServer-vX.Y-macos-{arm64,x86_64}.tar.gz.
- Templated media-server.service updated to match the dist layout with
proper session-bus env vars and a writable state-dir grant.
- install_linux.sh: drop dead requirements.txt path; install via
`pip install ".[linux]"` and pre-create the writable state dirs.
- Cross-platform album artwork: abstract MediaController.get_album_art()
with Linux (mpris:artUrl, file:// + http(s)://) and macOS (Spotify URL)
impls; routes/media artwork endpoint now awaits the controller.
- LinuxMediaController connects to the session bus lazily — failure no
longer crashes lifespan startup; MPRIS calls return idle until the bus
is reachable. Logged once at INFO with a hint about
`loginctl enable-linger`.
- Startup preflight on Linux warns if DBUS_SESSION_BUS_ADDRESS or
XDG_RUNTIME_DIR is unset and informs the user when Wayland disables
the foreground probe.
- /api/media/visualizer/status now reports a per-OS unavailable_reason.
- tray._confirm guarded against ctypes.windll on non-Windows.
- config.example.yaml: per-OS commented script examples; on_turn_off
default is now a no-op echo (used to silently fail off Windows).
- README: replace stale `pip install -r requirements.txt` instructions
with the new extras; add systemd lingering doc + troubleshooting
section; add macOS LaunchAgent section.
- CI: new linux-smoke job (installs `.[linux]`, boots the server under
dbus-run-session, asserts /api/health). Release workflow gains
apt-deps step for the Linux build and a best-effort macOS build job.
118 lines
2.7 KiB
Python
118 lines
2.7 KiB
Python
"""Abstract base class for media controllers."""
|
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
from ..models import MediaStatus
|
|
|
|
|
|
class MediaController(ABC):
|
|
"""Abstract base class for platform-specific media controllers."""
|
|
|
|
@abstractmethod
|
|
async def get_status(self) -> MediaStatus:
|
|
"""Get the current media playback status.
|
|
|
|
Returns:
|
|
MediaStatus with current playback info
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
async def play(self) -> bool:
|
|
"""Resume or start playback.
|
|
|
|
Returns:
|
|
True if successful, False otherwise
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
async def pause(self) -> bool:
|
|
"""Pause playback.
|
|
|
|
Returns:
|
|
True if successful, False otherwise
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
async def stop(self) -> bool:
|
|
"""Stop playback.
|
|
|
|
Returns:
|
|
True if successful, False otherwise
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
async def next_track(self) -> bool:
|
|
"""Skip to the next track.
|
|
|
|
Returns:
|
|
True if successful, False otherwise
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
async def previous_track(self) -> bool:
|
|
"""Go to the previous track.
|
|
|
|
Returns:
|
|
True if successful, False otherwise
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
async def set_volume(self, volume: int) -> bool:
|
|
"""Set the system volume.
|
|
|
|
Args:
|
|
volume: Volume level (0-100)
|
|
|
|
Returns:
|
|
True if successful, False otherwise
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
async def toggle_mute(self) -> bool:
|
|
"""Toggle the mute state.
|
|
|
|
Returns:
|
|
The new mute state (True = muted)
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
async def seek(self, position: float) -> bool:
|
|
"""Seek to a position in the current track.
|
|
|
|
Args:
|
|
position: Position in seconds
|
|
|
|
Returns:
|
|
True if successful, False otherwise
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
async def open_file(self, file_path: str) -> bool:
|
|
"""Open a media file with the default system player.
|
|
|
|
Args:
|
|
file_path: Absolute path to the media file
|
|
|
|
Returns:
|
|
True if successful, False otherwise
|
|
"""
|
|
pass
|
|
|
|
async def get_album_art(self) -> bytes | None:
|
|
"""Return the current album art bytes, or ``None`` when unavailable.
|
|
|
|
Default impl returns ``None`` — controllers that can produce art
|
|
(Windows via SMTC thumbnail, Linux via mpris:artUrl, macOS via the
|
|
Spotify/Music artwork-url field) override this.
|
|
"""
|
|
return None
|