aboutsummaryrefslogtreecommitdiffstats
path: root/mediaplayer.py
diff options
context:
space:
mode:
authorEdi Feschiyan <edi.feschiyan@konsulko.com>2020-05-08 12:11:10 +0300
committerEdi Feschiyan <edi.feschiyan@konsulko.com>2020-05-08 12:11:10 +0300
commit219e992aa8a8e5a7db48cc9d66bb0ddbbe7c21a3 (patch)
treeb6a39f637851ad41f04420012fac5c659c4fae85 /mediaplayer.py
parentb2db7fb84b44c3c2cc464475b84494570f057882 (diff)
Adding requirements, work in progress to integrate this thing with pytest
Diffstat (limited to 'mediaplayer.py')
-rw-r--r--mediaplayer.py24
1 files changed, 9 insertions, 15 deletions
diff --git a/mediaplayer.py b/mediaplayer.py
index e7059b6..b916dd8 100644
--- a/mediaplayer.py
+++ b/mediaplayer.py
@@ -1,8 +1,6 @@
-import os
-import asyncio
-import json
-
from aglbaseservice import AGLBaseService
+import asyncio
+import os
class MediaPlayerService(AGLBaseService):
@@ -13,19 +11,15 @@ class MediaPlayerService(AGLBaseService):
super().__init__(api='mediaplayer', ip=ip, port=port, service='agl-service-mediaplayer')
async def playlist(self, waitresponse=False):
- if waitresponse:
- return await self.request('playlist', waitresponse=waitresponse)
- else:
- await self.request('playlist')
+ return await self.request('playlist', waitresponse=waitresponse)
- async def subscribe(self, event='metadata'):
- await super().subscribe(event=event)
+ async def subscribe(self, event='metadata', waitresponse=False):
+ await super().subscribe(event=event, waitresponse=waitresponse)
- async def unsubscribe(self, event='metadata'):
- await super().subscribe(event=event)
+ async def unsubscribe(self, event='metadata', waitresponse=False):
+ await super().subscribe(event=event, waitresponse=waitresponse)
- async def control(self, name, value=None):
- verb = 'controls'
+ async def control(self, name, value=None, waitresponse=False):
loopstate = ['off', 'playlist', 'track']
controls = {
'play': None,
@@ -59,7 +53,7 @@ class MediaPlayerService(AGLBaseService):
assert value in loopstate, f'Tried to set invalid loopstate - {value}, use "off", "playlist" or "track"'
msg = {'value': name, controls[name]: str(value)}
- await self.request(verb, msg)
+ await self.request('controls', msg, waitresponse=waitresponse)
async def main(loop):