Better way to detect video widget playback

This commit is contained in:
croneter 2019-05-04 16:13:26 +02:00
parent 353cb04532
commit 45fc9fa8be
3 changed files with 4 additions and 25 deletions

View file

@ -59,9 +59,6 @@ class PlayState(object):
self.resume_playback = None
# Don't ask user whether to resume but immediatly resume
self.autoplay = False
# Are we using the Kodi audio playlist (=True, e.g. for videos when
# starting from a widget!) or video playlist (=False)?
self.audioplaylist = None
# Was the playback initiated by the user using the Kodi context menu?
self.context_menu_play = False
# Which Kodi player is/has been active? (either int 1, 2 or 3)

View file

@ -184,7 +184,7 @@ class KodiMonitor(xbmc.Monitor):
def _playlist_onadd(self, data):
'''
Detect widget playback. Widget for some reason, use audio playlists.
Called when a new item is added to a Kodi playqueue
'''
if 'item' in data and data['item'].get('type') == v.KODI_TYPE_SHOW:
# Hitting the "browse" button on tv show info dialog
@ -195,16 +195,9 @@ class KodiMonitor(xbmc.Monitor):
return
if data['position'] == 0:
if data['playlistid'] == 0:
app.PLAYSTATE.audioplaylist = True
LOG.error('app.PLAYSTATE.audioplaylist set to True')
else:
app.PLAYSTATE.audioplaylist = False
LOG.error('app.PLAYSTATE.audioplaylist set to False')
self.playlistid = data['playlistid']
LOG.debug('plex.playlist.start: %s', utils.window('plex.playlist.start'))
if utils.window('plex.playlist.start') and data['position'] == int(utils.window('plex.playlist.start')):
LOG.info('Playlist ready')
LOG.debug('Playlist ready')
utils.window('plex.playlist.ready', value='true')
utils.window('plex.playlist.start', clear=True)

View file

@ -328,17 +328,8 @@ class QueuePlay(backgroundthread.KillableThread):
LOG.debug('##===---- Starting QueuePlay ----===##')
abort = False
play_folder = False
i = 0
while app.PLAYSTATE.audioplaylist is None:
# Needed particulary for widget-playback
# We need to wait until kodimonitor notification OnAdd is triggered
# in order to detect the playlist type (video vs. audio) and thus
# e.g. determine whether playback has been init. from widgets
xbmc.sleep(50)
i += 1
if i > 100:
raise Exception('Kodi OnAdd not received - cancelling')
if app.PLAYSTATE.audioplaylist and self.plex_type in v.PLEX_VIDEOTYPES:
if (self.plex_type in v.PLEX_VIDEOTYPES and
xbmc.getCondVisibility('Window.IsVisible(Home.xml)')):
# Video launched from a widget - which starts a Kodi AUDIO playlist
# We will empty everything and start with a fresh VIDEO playlist
LOG.debug('Widget video playback detected; relaunching')
@ -393,7 +384,6 @@ class QueuePlay(backgroundthread.KillableThread):
elif video_widget_playback:
LOG.info('Start widget video playback')
utils.window('plex.playlist.play', value='true')
xbmc.sleep(2000)
LOG.info('Current PKC queue: %s', playqueue)
LOG.info('current Kodi queue: %s', js.playlist_get_items(playqueue.playlistid))
playqueue.start_playback()
@ -453,7 +443,6 @@ class QueuePlay(backgroundthread.KillableThread):
utils.window('plex.playlist.ready', clear=True)
utils.window('plex.playlist.start', clear=True)
app.PLAYSTATE.audioplaylist = None
self.server.threads.remove(self)
self.server.pending = []
LOG.debug('##===---- QueuePlay Stopped ----===##')