Skip to content

Commit

Permalink
Add state detection for Plex on Fire TV (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffLIrion committed Nov 13, 2019
1 parent cd58cd8 commit e83bcba
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions androidtv/firetv.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,16 @@ def update(self, get_running_apps=True):
else:
state = constants.STATE_STANDBY

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

# Sport 1
elif current_app == constants.APP_SPORT1:
if wake_lock_size == 2:
Expand Down
10 changes: 10 additions & 0 deletions tests/test_firetv.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,16 @@ def test_state_detection(self):
self.assertUpdate([True, True, 1, constants.APP_NETFLIX, 1, [constants.APP_NETFLIX]],
(constants.STATE_STANDBY, constants.APP_NETFLIX, [constants.APP_NETFLIX]))

# Plex
self.assertUpdate([True, True, 1, constants.APP_PLEX, 3, [constants.APP_PLEX]],
(constants.STATE_PLAYING, constants.APP_PLEX, [constants.APP_PLEX]))

self.assertUpdate([True, True, 2, constants.APP_PLEX, 3, [constants.APP_PLEX]],
(constants.STATE_PAUSED, constants.APP_PLEX, [constants.APP_PLEX]))

self.assertUpdate([True, True, 1, constants.APP_PLEX, 1, [constants.APP_PLEX]],
(constants.STATE_STANDBY, constants.APP_PLEX, [constants.APP_PLEX]))

# Sport 1
self.assertUpdate([True, True, 3, constants.APP_SPORT1, 3, [constants.APP_SPORT1]],
(constants.STATE_PLAYING, constants.APP_SPORT1, [constants.APP_SPORT1]))
Expand Down

0 comments on commit e83bcba

Please sign in to comment.