Fixes to add-on paths playback startup
This commit is contained in:
parent
5af5412009
commit
62e973dbe2
3 changed files with 27 additions and 13 deletions
|
@ -209,17 +209,15 @@ class KodiMonitor(Monitor):
|
||||||
}
|
}
|
||||||
Will NOT be called if playback initiated by Kodi widgets
|
Will NOT be called if playback initiated by Kodi widgets
|
||||||
"""
|
"""
|
||||||
kodi_item = js.get_item(data['playlistid'])
|
old = state.OLD_PLAYER_STATES[data['playlistid']]
|
||||||
if (state.RESUMABLE is True and not kodi_item['file'] and
|
if (not state.DIRECT_PATHS and data['position'] == 0 and
|
||||||
data['position'] == 0 and
|
not PQ.PLAYQUEUES[data['playlistid']].items and
|
||||||
data['item'].get('title') is not None and
|
data['item']['type'] == old['kodi_type'] and
|
||||||
getCondVisibility('Window.IsVisible(MyVideoNav.xml)')):
|
data['item']['id'] == old['kodi_id']):
|
||||||
# Hack we need for RESUMABLE items because Kodi lost the path of the
|
# Hack we need for RESUMABLE items because Kodi lost the path of the
|
||||||
# last played item that is now being replayed (see playback.py's
|
# last played item that is now being replayed (see playback.py's
|
||||||
# Player().play())
|
# Player().play()) Also see playqueue.py _compare_playqueues()
|
||||||
# Also see playqueue.py _compare_playqueues()
|
|
||||||
LOG.info('Detected re-start of playback of last item')
|
LOG.info('Detected re-start of playback of last item')
|
||||||
old = state.OLD_PLAYER_STATES[data['playlistid']]
|
|
||||||
kwargs = {
|
kwargs = {
|
||||||
'plex_id': old['plex_id'],
|
'plex_id': old['plex_id'],
|
||||||
'plex_type': old['plex_type'],
|
'plex_type': old['plex_type'],
|
||||||
|
@ -240,6 +238,7 @@ class KodiMonitor(Monitor):
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@LOCKER.lockthis
|
||||||
def _playlist_onclear(self, data):
|
def _playlist_onclear(self, data):
|
||||||
"""
|
"""
|
||||||
Called if a Kodi playlist is cleared. Example data dict:
|
Called if a Kodi playlist is cleared. Example data dict:
|
||||||
|
@ -247,7 +246,11 @@ class KodiMonitor(Monitor):
|
||||||
u'playlistid': 1,
|
u'playlistid': 1,
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
pass
|
playqueue = PQ.PLAYQUEUES[data['playlistid']]
|
||||||
|
if not playqueue.is_pkc_clear():
|
||||||
|
playqueue.clear(kodi=False)
|
||||||
|
else:
|
||||||
|
LOG.debug('Detected PKC clear - ignoring')
|
||||||
|
|
||||||
def _get_ids(self, json_item):
|
def _get_ids(self, json_item):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -37,10 +37,6 @@ def playback_cleanup():
|
||||||
DU().downloadUrl(
|
DU().downloadUrl(
|
||||||
'{server}/video/:/transcode/universal/stop',
|
'{server}/video/:/transcode/universal/stop',
|
||||||
parameters={'session': v.PKC_MACHINE_IDENTIFIER})
|
parameters={'session': v.PKC_MACHINE_IDENTIFIER})
|
||||||
# Kodi will not clear the playqueue (because there is not really any)
|
|
||||||
# if there is only 1 item in it
|
|
||||||
if len(PQ.PLAYQUEUES[playerid].items) == 1:
|
|
||||||
PQ.PLAYQUEUES[playerid].clear()
|
|
||||||
# Reset the player's status
|
# Reset the player's status
|
||||||
status = dict(state.PLAYSTATE)
|
status = dict(state.PLAYSTATE)
|
||||||
# As all playback has halted, reset the players that have been active
|
# As all playback has halted, reset the players that have been active
|
||||||
|
|
|
@ -48,6 +48,8 @@ class PlaylistObjectBaseclase(object):
|
||||||
self.plex_transient_token = None
|
self.plex_transient_token = None
|
||||||
# Need a hack for detecting swaps of elements
|
# Need a hack for detecting swaps of elements
|
||||||
self.old_kodi_pl = []
|
self.old_kodi_pl = []
|
||||||
|
# Workaround to avoid endless loops of detecting PL clears
|
||||||
|
self._clear_list = []
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
"""
|
"""
|
||||||
|
@ -67,6 +69,18 @@ class PlaylistObjectBaseclase(object):
|
||||||
answ += '\'%s\': %s, ' % (key, str(getattr(self, key)))
|
answ += '\'%s\': %s, ' % (key, str(getattr(self, key)))
|
||||||
return answ + '\'items\': %s}}' % self.items
|
return answ + '\'items\': %s}}' % self.items
|
||||||
|
|
||||||
|
def is_pkc_clear(self):
|
||||||
|
"""
|
||||||
|
Returns True if PKC has cleared the Kodi playqueue just recently.
|
||||||
|
Then this clear will be ignored from now on
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
self._clear_list.pop()
|
||||||
|
except IndexError:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
def clear(self, kodi=True):
|
def clear(self, kodi=True):
|
||||||
"""
|
"""
|
||||||
Resets the playlist object to an empty playlist.
|
Resets the playlist object to an empty playlist.
|
||||||
|
@ -76,6 +90,7 @@ class PlaylistObjectBaseclase(object):
|
||||||
# kodi monitor's on_clear method will only be called if there were some
|
# kodi monitor's on_clear method will only be called if there were some
|
||||||
# items to begin with
|
# items to begin with
|
||||||
if kodi and self.kodi_pl.size() != 0:
|
if kodi and self.kodi_pl.size() != 0:
|
||||||
|
self._clear_list.append(None)
|
||||||
self.kodi_pl.clear() # Clear Kodi playlist object
|
self.kodi_pl.clear() # Clear Kodi playlist object
|
||||||
self.items = []
|
self.items = []
|
||||||
self.id = None
|
self.id = None
|
||||||
|
|
Loading…
Reference in a new issue