"""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
