Fix playstate remaining at zero

This commit is contained in:
croneter 2017-12-14 10:34:40 +01:00
parent 8189eb6b4c
commit b520fe2b79
2 changed files with 24 additions and 0 deletions

View file

@ -407,6 +407,19 @@ def get_player_props(playerid):
'currentsubtitle']})['result'] 'currentsubtitle']})['result']
def current_state(playerid):
"""
Returns a dict for the active Kodi player with the following values:
(values that change from second to second with no monitoring possible)
{
'time' The current item's time in Kodi time
}
"""
return jsonrpc('Player.GetProperties').execute({
'playerid': playerid,
'properties': ['time']})['result']
def current_audiostream(playerid): def current_audiostream(playerid):
""" """
Returns a dict of the active audiostream for playerid [int]: Returns a dict of the active audiostream for playerid [int]:

View file

@ -115,6 +115,16 @@ class SubscriptionMgr(object):
state.PLAYER_STATES[playerid]['plex_id'] state.PLAYER_STATES[playerid]['plex_id']
return key return key
def _set_current_details(self, playerid):
"""
Sets the current details for the player with playerid in state.py:
PLAYER_STATES[playerid]{
'time'
}
"""
state.PLAYER_STATES[playerid].update(js.current_state(playerid))
def _kodi_stream_index(self, playerid, stream_type): def _kodi_stream_index(self, playerid, stream_type):
""" """
Returns the current Kodi stream index [int] for the player playerid Returns the current Kodi stream index [int] for the player playerid
@ -131,6 +141,7 @@ class SubscriptionMgr(object):
return ' <Timeline state="stopped" controllable="%s" type="%s" ' \ return ' <Timeline state="stopped" controllable="%s" type="%s" ' \
'itemType="%s" />\n' % (CONTROLLABLE[ptype], ptype, ptype) 'itemType="%s" />\n' % (CONTROLLABLE[ptype], ptype, ptype)
playerid = player['playerid'] playerid = player['playerid']
self._set_current_details(playerid)
info = state.PLAYER_STATES[playerid] info = state.PLAYER_STATES[playerid]
status = 'paused' if info['speed'] == '0' else 'playing' status = 'paused' if info['speed'] == '0' else 'playing'
ret = ' <Timeline state="%s"' % status ret = ' <Timeline state="%s"' % status