Better way to detect video widget playback
This commit is contained in:
parent
353cb04532
commit
45fc9fa8be
3 changed files with 4 additions and 25 deletions
|
@ -59,9 +59,6 @@ class PlayState(object):
|
||||||
self.resume_playback = None
|
self.resume_playback = None
|
||||||
# Don't ask user whether to resume but immediatly resume
|
# Don't ask user whether to resume but immediatly resume
|
||||||
self.autoplay = False
|
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?
|
# Was the playback initiated by the user using the Kodi context menu?
|
||||||
self.context_menu_play = False
|
self.context_menu_play = False
|
||||||
# Which Kodi player is/has been active? (either int 1, 2 or 3)
|
# Which Kodi player is/has been active? (either int 1, 2 or 3)
|
||||||
|
|
|
@ -184,7 +184,7 @@ class KodiMonitor(xbmc.Monitor):
|
||||||
|
|
||||||
def _playlist_onadd(self, data):
|
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:
|
if 'item' in data and data['item'].get('type') == v.KODI_TYPE_SHOW:
|
||||||
# Hitting the "browse" button on tv show info dialog
|
# Hitting the "browse" button on tv show info dialog
|
||||||
|
@ -195,16 +195,9 @@ class KodiMonitor(xbmc.Monitor):
|
||||||
return
|
return
|
||||||
|
|
||||||
if data['position'] == 0:
|
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']
|
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')):
|
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.ready', value='true')
|
||||||
utils.window('plex.playlist.start', clear=True)
|
utils.window('plex.playlist.start', clear=True)
|
||||||
|
|
||||||
|
|
|
@ -328,17 +328,8 @@ class QueuePlay(backgroundthread.KillableThread):
|
||||||
LOG.debug('##===---- Starting QueuePlay ----===##')
|
LOG.debug('##===---- Starting QueuePlay ----===##')
|
||||||
abort = False
|
abort = False
|
||||||
play_folder = False
|
play_folder = False
|
||||||
i = 0
|
if (self.plex_type in v.PLEX_VIDEOTYPES and
|
||||||
while app.PLAYSTATE.audioplaylist is None:
|
xbmc.getCondVisibility('Window.IsVisible(Home.xml)')):
|
||||||
# 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:
|
|
||||||
# Video launched from a widget - which starts a Kodi AUDIO playlist
|
# Video launched from a widget - which starts a Kodi AUDIO playlist
|
||||||
# We will empty everything and start with a fresh VIDEO playlist
|
# We will empty everything and start with a fresh VIDEO playlist
|
||||||
LOG.debug('Widget video playback detected; relaunching')
|
LOG.debug('Widget video playback detected; relaunching')
|
||||||
|
@ -393,7 +384,6 @@ class QueuePlay(backgroundthread.KillableThread):
|
||||||
elif video_widget_playback:
|
elif video_widget_playback:
|
||||||
LOG.info('Start widget video playback')
|
LOG.info('Start widget video playback')
|
||||||
utils.window('plex.playlist.play', value='true')
|
utils.window('plex.playlist.play', value='true')
|
||||||
xbmc.sleep(2000)
|
|
||||||
LOG.info('Current PKC queue: %s', playqueue)
|
LOG.info('Current PKC queue: %s', playqueue)
|
||||||
LOG.info('current Kodi queue: %s', js.playlist_get_items(playqueue.playlistid))
|
LOG.info('current Kodi queue: %s', js.playlist_get_items(playqueue.playlistid))
|
||||||
playqueue.start_playback()
|
playqueue.start_playback()
|
||||||
|
@ -453,7 +443,6 @@ class QueuePlay(backgroundthread.KillableThread):
|
||||||
|
|
||||||
utils.window('plex.playlist.ready', clear=True)
|
utils.window('plex.playlist.ready', clear=True)
|
||||||
utils.window('plex.playlist.start', clear=True)
|
utils.window('plex.playlist.start', clear=True)
|
||||||
app.PLAYSTATE.audioplaylist = None
|
|
||||||
self.server.threads.remove(self)
|
self.server.threads.remove(self)
|
||||||
self.server.pending = []
|
self.server.pending = []
|
||||||
LOG.debug('##===---- QueuePlay Stopped ----===##')
|
LOG.debug('##===---- QueuePlay Stopped ----===##')
|
||||||
|
|
Loading…
Reference in a new issue