Rewire detection of add-on paths playlists playback
- Pain to fix Kodi bugs
This commit is contained in:
parent
e09cfa8cb3
commit
0a55e7fee8
3 changed files with 45 additions and 21 deletions
|
@ -216,6 +216,18 @@ class KodiMonitor(xbmc.Monitor):
|
|||
}
|
||||
Will NOT be called if playback initiated by Kodi widgets
|
||||
"""
|
||||
if data['item'] == {'type': 'unknown'}:
|
||||
# Kodi will return something like this if user started a PLAYLIST
|
||||
# from add-on paths:
|
||||
# {u'item': {u'type': u'unknown'},
|
||||
# u'playlistid': 0,
|
||||
# u'position': 4}
|
||||
if not state.PLAYLIST_PLAY:
|
||||
LOG.debug('Detected playback from a playlist')
|
||||
state.PLAYLIST_PLAY = True
|
||||
return
|
||||
else:
|
||||
state.PLAYLIST_PLAY = False
|
||||
if 'id' not in data['item']:
|
||||
return
|
||||
old = state.OLD_PLAYER_STATES[data['playlistid']]
|
||||
|
|
|
@ -60,14 +60,21 @@ def playback_triage(plex_id=None, plex_type=None, path=None, resolve=True):
|
|||
dialog('notification', lang(29999), lang(30017))
|
||||
_ensure_resolve(abort=True)
|
||||
return
|
||||
if state.PLAYLIST_PLAY:
|
||||
LOG.debug('Kodi playlist play detected')
|
||||
state.PLAYLIST_PLAY = False
|
||||
_playlist_playback(plex_id, plex_type)
|
||||
return
|
||||
playqueue = PQ.get_playqueue_from_type(
|
||||
v.KODI_PLAYLIST_TYPE_FROM_PLEX_TYPE[plex_type])
|
||||
try:
|
||||
pos = js.get_position(playqueue.playlistid)
|
||||
except KeyError:
|
||||
LOG.info('No position returned from Kodi player! Assuming playlist')
|
||||
_playlist_playback(plex_id, plex_type)
|
||||
else:
|
||||
LOG.error('No position returned from Kodi player!')
|
||||
# "Play error"
|
||||
dialog('notification', lang(29999), lang(30128), icon='{error}')
|
||||
_ensure_resolve(abort=True)
|
||||
return
|
||||
# Can return -1 (as in "no playlist")
|
||||
pos = pos if pos != -1 else 0
|
||||
LOG.debug('playQueue position %s for %s', pos, playqueue)
|
||||
|
@ -102,9 +109,6 @@ def _playlist_playback(plex_id, plex_type):
|
|||
for the next item in line :-)
|
||||
(by the way: trying to get active Kodi player id will return [])
|
||||
"""
|
||||
# Kodi bug: playqueue will ALWAYS be audio playqueue
|
||||
playqueue = PQ.get_playqueue_from_type(v.KODI_PLAYLIST_TYPE_AUDIO)
|
||||
playqueue.clear(kodi=False)
|
||||
xml = GetPlexMetadata(plex_id)
|
||||
try:
|
||||
xml[0].attrib
|
||||
|
@ -114,9 +118,15 @@ def _playlist_playback(plex_id, plex_type):
|
|||
dialog('notification', lang(29999), lang(30128), icon='{error}')
|
||||
_ensure_resolve(abort=True)
|
||||
return
|
||||
# Kodi bug: playqueue will ALWAYS be audio playqueue UNTIL playback
|
||||
# has actually started. Need to tell Kodimonitor
|
||||
playqueue = PQ.get_playqueue_from_type(v.KODI_PLAYLIST_TYPE_AUDIO)
|
||||
playqueue.clear(kodi=False)
|
||||
# Set the flag for the potentially WRONG audio playlist so Kodimonitor
|
||||
# can pick up on it
|
||||
playqueue.kodi_playlist_playback = True
|
||||
playlist_item = PL.playlist_item_from_xml(xml[0])
|
||||
playqueue.items.append(playlist_item)
|
||||
playqueue.kodi_playlist_playback = True
|
||||
_conclude_playback(playqueue, pos=0)
|
||||
|
||||
|
||||
|
|
|
@ -160,6 +160,8 @@ RESUME_PLAYBACK = False
|
|||
CONTEXT_MENU_PLAY = False
|
||||
# Set by context menu - shall we force-transcode the next playing item?
|
||||
FORCE_TRANSCODE = False
|
||||
# Flag if user started playback of a PLAYLIST (not playqueue) for add-on paths
|
||||
PLAYLIST_PLAY = False
|
||||
|
||||
# Kodi webserver details
|
||||
WEBSERVER_PORT = 8080
|
||||
|
|
Loading…
Reference in a new issue