Skip to content

Commit

Permalink
Merge b694faa into 5c39196
Browse files Browse the repository at this point in the history
  • Loading branch information
aav7fl committed Oct 21, 2019
2 parents 5c39196 + b694faa commit c3446e4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
8 changes: 7 additions & 1 deletion androidtv/androidtv.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,13 @@ def update(self):

# Plex
elif current_app == constants.APP_PLEX:
state = audio_state
if media_session_state == 3:
if wake_lock_size == 1:
state = constants.STATE_PAUSED
else:
state = constants.STATE_PLAYING
else:
state = constants.STATE_STANDBY

# TVheadend
elif current_app == constants.APP_TVHEADEND:
Expand Down
4 changes: 2 additions & 2 deletions androidtv/basetv.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class BaseTV(object):
'com.ellation.vrv': ['audio_state'],
'com.hulu.plus': [{'playing': {'wake_lock_size' : 4}},
{'paused': {'wake_lock_size': 2}}],
'com.plexapp.android': [{'playing': {'media_session_state': 3, 'wake_lock_size': 3}},
{'paused': {'media_session_state': 3, 'wake_lock_size': 1}},
'com.plexapp.android': [{'paused': {'media_session_state': 3, 'wake_lock_size': 1}},
{'playing': {'media_session_state': 3}},
'standby']}
The keys are app IDs, and the values are lists of rules that are evaluated in order.
Expand Down
17 changes: 16 additions & 1 deletion tests/test_androidtv.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,22 @@ def test_state_detection(self):

# Plex
self.assertUpdate([True, True, constants.STATE_IDLE, 2, constants.APP_PLEX, 4, 'hmdi_arc', False, 30],
(constants.STATE_IDLE, constants.APP_PLEX, 'hmdi_arc', False, 0.5))
(constants.STATE_STANDBY, constants.APP_PLEX, 'hmdi_arc', False, 0.5))

self.assertUpdate([True, True, constants.STATE_IDLE, 3, constants.APP_PLEX, 3, 'hmdi_arc', False, 30],
(constants.STATE_PLAYING, constants.APP_PLEX, 'hmdi_arc', False, 0.5))

self.assertUpdate([True, True, constants.STATE_IDLE, 4, constants.APP_PLEX, 3, 'hmdi_arc', False, 30],
(constants.STATE_PLAYING, constants.APP_PLEX, 'hmdi_arc', False, 0.5))

self.assertUpdate([True, True, constants.STATE_IDLE, 5, constants.APP_PLEX, 3, 'hmdi_arc', False, 30],
(constants.STATE_PLAYING, constants.APP_PLEX, 'hmdi_arc', False, 0.5))

self.assertUpdate([True, True, constants.STATE_IDLE, 7, constants.APP_PLEX, 3, 'hmdi_arc', False, 30],
(constants.STATE_PLAYING, constants.APP_PLEX, 'hmdi_arc', False, 0.5))

self.assertUpdate([True, True, constants.STATE_IDLE, 1, constants.APP_PLEX, 3, 'hmdi_arc', False, 30],
(constants.STATE_PAUSED, constants.APP_PLEX, 'hmdi_arc', False, 0.5))

# TVheadend
self.assertUpdate([True, True, constants.STATE_IDLE, 5, constants.APP_TVHEADEND, 4, 'hmdi_arc', False, 30],
Expand Down

0 comments on commit c3446e4

Please sign in to comment.