Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions afsapi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions afsapi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class PlayState(IntEnum):


class PlayControl(IntEnum):
STOP = 0
PLAY = 1
PAUSE = 2
NEXT = 3
Expand Down
13 changes: 10 additions & 3 deletions async_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down