Skip to content

Commit

Permalink
new media player interface
Browse files Browse the repository at this point in the history
  • Loading branch information
BruceZhang1993 committed Feb 7, 2024
1 parent af7b096 commit 150ca66
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 1 deletion.
13 changes: 13 additions & 0 deletions aionowplaying/enum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from enum import StrEnum


class PlaybackStatus(str, StrEnum):
Playing = 'Playing'
Paused = 'Paused'
Stopped = 'Stopped'


class LoopStatus(str, StrEnum):
None_ = 'None'
Track = 'Track'
Playlist = 'Playlist'
77 changes: 76 additions & 1 deletion aionowplaying/interface.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from abc import ABCMeta, abstractmethod
from typing import List, Optional

from aionowplaying.enum import PlaybackStatus, LoopStatus


# noinspection PyPep8Naming
class MediaPlayerInterface(metaclass=ABCMeta):
class MPInterface(metaclass=ABCMeta):
"""
Media player definitions of aionp
All media players using aionp should implement this interface
Expand Down Expand Up @@ -124,3 +126,76 @@ def quit(self):
You must implement this method if canQuit is set to true.
"""
pass


# noinspection PyPep8Naming
class MPPlayerInterface(metaclass=ABCMeta):
@property
@abstractmethod
def canGoNext(self) -> bool:
pass

def next(self):
pass

@property
@abstractmethod
def canGoPrevious(self) -> bool:
pass

def previous(self):
pass

@property
@abstractmethod
def canPause(self) -> bool:
pass

def pause(self):
pass

def playPause(self):
pass

@property
@abstractmethod
def canControl(self) -> bool:
pass

def stop(self):
pass

@property
def loopStatus(self) -> Optional[LoopStatus]:
return None

@loopStatus.setter
def loopStatus(self, status: LoopStatus):
pass

@property
@abstractmethod
def canPlay(self) -> bool:
pass

def play(self):
pass

@property
@abstractmethod
def canSeek(self) -> bool:
pass

def seek(self, offset: int):
pass

def setPosition(self, trackId: str, position: int):
pass

def openUri(self, uri: str):
pass

@property
@abstractmethod
def playbackStatus(self) -> PlaybackStatus:
pass

0 comments on commit 150ca66

Please sign in to comment.