forked from easink/aioheos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
executable file
·63 lines (48 loc) · 1.33 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
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python3
" Heos python lib "
import asyncio
import aioheos
@asyncio.coroutine
def heos_test(loop):
""" test heos """
verbose = True
# host = None
host = '192.168.1.17'
username = None
password = None
heos = aioheos.AioHeos(loop, host, username, password, verbose=verbose)
# connect to player
yield from heos.connect()
heos.request_play_state()
# heos.request_mute_state()
# heos.request_volume()
# heos.set_volume(10)
# heos.request_groups()
# heos.request_music_sources()
# heos.request_browse_source(1028)
# s25777 Sublime
# s75171 538 Dance Department
# s45142 Pingiuin Radio
# s9067 Sky Radio
# heos.play_favourite('s75171') # 538 Dance Department
# with open('hello.mp3', mode='rb') as fhello:
# content = fhello.read()
# content_type = 'audio/mpeg'
# heos.play_content(content, content_type)
# do some work...
yield from asyncio.sleep(2)
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()