- FastAPI server for Windows media control via WinRT/SMTC - Home Assistant custom integration with media player entity - Script button entities for system commands - Position tracking with grace period for track skip handling - Server availability detection in HA entity Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
97 lines
2.0 KiB
Python
97 lines
2.0 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
|