Detect playback from playlist more reliable for add-on paths
This commit is contained in:
parent
a36307e0aa
commit
c03b7c52c4
3 changed files with 25 additions and 24 deletions
|
@ -216,18 +216,6 @@ 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,21 +60,36 @@ 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.error('No position returned from Kodi player!')
|
||||
# Kodi bug - Playlist plays (not Playqueue) will ALWAYS be audio for
|
||||
# add-on paths
|
||||
LOG.info('No position returned from Kodi player! Assuming playlist')
|
||||
playqueue = PQ.get_playqueue_from_type(v.KODI_PLAYLIST_TYPE_AUDIO)
|
||||
try:
|
||||
pos = js.get_position(playqueue.playlistid)
|
||||
except KeyError:
|
||||
LOG.error('Still no position - abort')
|
||||
# "Play error"
|
||||
dialog('notification', lang(29999), lang(30128), icon='{error}')
|
||||
_ensure_resolve(abort=True)
|
||||
return
|
||||
# HACK to detect playback of playlists for add-on paths
|
||||
items = js.playlist_get_items(playqueue.playlistid)
|
||||
try:
|
||||
item = items[pos]
|
||||
except IndexError:
|
||||
LOG.info('Could not apply playlist hack! Probably Widget playback')
|
||||
else:
|
||||
if ('id' not in item and
|
||||
item.get('type') == 'unknown' and item.get('title') == ''):
|
||||
LOG.info('Kodi playlist play detected')
|
||||
_playlist_playback(plex_id, plex_type)
|
||||
return
|
||||
|
||||
# Can return -1 (as in "no playlist")
|
||||
pos = pos if pos != -1 else 0
|
||||
LOG.debug('playQueue position %s for %s', pos, playqueue)
|
||||
|
|
|
@ -160,8 +160,6 @@ 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