Skip to content

Commit f3d6ca1

Browse files
authored
Merge pull request #11 from SpeedyGoneZales/master
Fixed Playing and Pausing when in mode internet radio
2 parents f26bb51 + fa258e4 commit f3d6ca1

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

afsapi/api.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,10 @@ async def play_control(self, value: t.Union[PlayControl, int]) -> t.Optional[boo
517517
"""
518518
return await self.handle_set(API["control"], int(value))
519519

520+
async def stop(self) -> t.Optional[bool]:
521+
"""Stop (and Start) media."""
522+
return await self.play_control(PlayControl.STOP)
523+
520524
async def play(self) -> t.Optional[bool]:
521525
"""Play media."""
522526
return await self.play_control(PlayControl.PLAY)

afsapi/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class PlayState(IntEnum):
1111

1212

1313
class PlayControl(IntEnum):
14+
STOP = 0
1415
PLAY = 1
1516
PAUSE = 2
1617
NEXT = 3

async_tests.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,28 @@ async def test_play() -> None:
121121
status = await afsapi.get_play_status()
122122
print("Status: %s" % status)
123123

124+
pause = await afsapi.pause()
125+
print("Start play succeeded? - %s" % pause)
126+
await asyncio.sleep(2)
127+
124128
start_play = await afsapi.play()
125129
print("Start play succeeded? - %s" % start_play)
126-
await asyncio.sleep(1)
130+
await asyncio.sleep(2)
127131

128132
forward = await afsapi.forward()
129133
print("Next succeeded? - %s" % forward)
130-
await asyncio.sleep(1)
134+
await asyncio.sleep(2)
131135

132136
rewind = await afsapi.rewind()
133137
print("Prev succeeded? - %s" % rewind)
134138

139+
stop = await afsapi.stop()
140+
print("Stop play succeeded? - %s" % stop)
141+
await asyncio.sleep(2)
142+
135143
except Exception:
136144
logging.error(traceback.format_exc())
137145

138-
139146
loop = asyncio.new_event_loop()
140147

141148
loop.run_until_complete(test_sys())

0 commit comments

Comments
 (0)