Skip to content

Commit

Permalink
Suspend support for MRP
Browse files Browse the repository at this point in the history
  • Loading branch information
postlund committed Feb 23, 2018
1 parent ecda6df commit 874ed1c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pyatv/dmap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ def top_menu(self):
"""Press key topmenu."""
return self.apple_tv.controlprompt_cmd('topmenu')

async def suspend(self):
"""Suspend the device."""
# Not supported by DMAP
raise exceptions.NotSupportedError

def set_position(self, pos):
"""Seek in the current playing media."""
time_in_ms = int(pos)*1000
Expand Down
5 changes: 5 additions & 0 deletions pyatv/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ def top_menu(self):
"""Go to main menu (long press menu)."""
raise exceptions.NotSupportedError

@abstractmethod
def suspend(self):
"""Suspend the device."""
raise exceptions.NotSupportedError

@abstractmethod
def set_position(self, pos):
"""Seek in the current playing media."""
Expand Down
5 changes: 5 additions & 0 deletions pyatv/mrp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
'select': [1, 0x89],
'menu': [1, 0x86],
'top_menu': [12, 0x60],
'suspend': [1, 0x82],

# 'mic': [12, 0x04] # Siri
}
Expand Down Expand Up @@ -100,6 +101,10 @@ def top_menu(self):
"""Go to main menu (long press menu)."""
return self._press_key('top_menu')

async def suspend(self):
"""Suspend the device."""
self._press_key('suspend')

def set_position(self, pos):
"""Seek in the current playing media."""
raise exceptions.NotSupportedError
Expand Down
5 changes: 5 additions & 0 deletions tests/dmap/test_dmap_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ def get_connected_device(self, identifier):
details.add_service(AirPlayService(self.server.port))
return connect_to_apple_tv(details, self.loop)

@unittest_run_loop
async def test_not_supportedt(self):
with self.assertRaises(exceptions.NotSupportedError):
await self.atv.remote_control.suspend()

# This is not a pretty test and it does crazy things. Should probably be
# re-written later but will do for now.
@unittest_run_loop
Expand Down

0 comments on commit 874ed1c

Please sign in to comment.