-
Notifications
You must be signed in to change notification settings - Fork 6
/
test.py
executable file
·54 lines (39 loc) · 1.06 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3
"""Heos python lib."""
import asyncio
import aioheos
async def heos_test(loop):
"""Test heos."""
verbose = True
# host = None
host = 'HEOS-1'
heos = aioheos.AioHeosController(loop, host=host)
# connect to player
await heos.connect()
player_one = heos.get_players()[0]
player_one.request_update()
player_one.set_volume(10)
await asyncio.sleep(1)
print(player_one.volume)
heos.request_groups()
# with open('hello.mp3', mode='rb') as fhello:
# content = fhello.read()
# content_type = 'audio/mpeg'
# player_one.play_content(content, content_type)
# do some work...
await asyncio.sleep(2)
await heos.close()
def main():
"""Main."""
loop = asyncio.get_event_loop()
heos_task = loop.create_task(heos_test(loop))
try:
loop.run_until_complete(heos_task)
except KeyboardInterrupt:
pass
# for task in asyncio.Task.all_tasks():
# task.cancel()
finally:
loop.close()
if __name__ == "__main__":
main()