diff --git a/afsapi/api.py b/afsapi/api.py index 21c7b3c..b355a55 100644 --- a/afsapi/api.py +++ b/afsapi/api.py @@ -517,6 +517,10 @@ async def play_control(self, value: t.Union[PlayControl, int]) -> t.Optional[boo """ return await self.handle_set(API["control"], int(value)) + async def stop(self) -> t.Optional[bool]: + """Stop (and Start) media.""" + return await self.play_control(PlayControl.STOP) + async def play(self) -> t.Optional[bool]: """Play media.""" return await self.play_control(PlayControl.PLAY) diff --git a/afsapi/models.py b/afsapi/models.py index e87c543..f341f61 100644 --- a/afsapi/models.py +++ b/afsapi/models.py @@ -11,6 +11,7 @@ class PlayState(IntEnum): class PlayControl(IntEnum): + STOP = 0 PLAY = 1 PAUSE = 2 NEXT = 3 diff --git a/async_tests.py b/async_tests.py index afeac4b..4316eb9 100644 --- a/async_tests.py +++ b/async_tests.py @@ -121,21 +121,28 @@ async def test_play() -> None: status = await afsapi.get_play_status() print("Status: %s" % status) + pause = await afsapi.pause() + print("Start play succeeded? - %s" % pause) + await asyncio.sleep(2) + start_play = await afsapi.play() print("Start play succeeded? - %s" % start_play) - await asyncio.sleep(1) + await asyncio.sleep(2) forward = await afsapi.forward() print("Next succeeded? - %s" % forward) - await asyncio.sleep(1) + await asyncio.sleep(2) rewind = await afsapi.rewind() print("Prev succeeded? - %s" % rewind) + stop = await afsapi.stop() + print("Stop play succeeded? - %s" % stop) + await asyncio.sleep(2) + except Exception: logging.error(traceback.format_exc()) - loop = asyncio.new_event_loop() loop.run_until_complete(test_sys())