Rewire autoplay flag

This commit is contained in:
croneter 2019-04-07 13:27:26 +02:00
parent 12befecc4a
commit 439857a9ce
3 changed files with 10 additions and 7 deletions

View file

@ -57,6 +57,8 @@ class PlayState(object):
# from the beginning? # from the beginning?
# Do set to None if NO resume dialog is displayed! True/False otherwise # Do set to None if NO resume dialog is displayed! True/False otherwise
self.resume_playback = None self.resume_playback = None
# Don't ask user whether to resume but immediatly resume
self.autoplay = False
# 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
# Set by context menu - shall we force-transcode the next playing item? # Set by context menu - shall we force-transcode the next playing item?

View file

@ -32,6 +32,7 @@ class KodiMonitor(xbmc.Monitor):
def __init__(self): def __init__(self):
self._already_slept = False self._already_slept = False
self.hack_replay = None self.hack_replay = None
self.playlistid = None
xbmc.Monitor.__init__(self) xbmc.Monitor.__init__(self)
for playerid in app.PLAYSTATE.player_states: for playerid in app.PLAYSTATE.player_states:
app.PLAYSTATE.player_states[playerid] = copy.deepcopy(app.PLAYSTATE.template) app.PLAYSTATE.player_states[playerid] = copy.deepcopy(app.PLAYSTATE.template)
@ -202,14 +203,16 @@ class KodiMonitor(xbmc.Monitor):
""" """
pass pass
@staticmethod def _playlist_onclear(self, data):
def _playlist_onclear(data):
""" """
Called if a Kodi playlist is cleared. Example data dict: Called if a Kodi playlist is cleared. Example data dict:
{ {
u'playlistid': 1, u'playlistid': 1,
} }
""" """
if self.playlistid == data['playlistid']:
LOG.debug('Resetting autoplay')
app.PLAYSTATE.autoplay = False
playqueue = PQ.PLAYQUEUES[data['playlistid']] playqueue = PQ.PLAYQUEUES[data['playlistid']]
if not playqueue.is_pkc_clear(): if not playqueue.is_pkc_clear():
playqueue.pkc_edit = True playqueue.pkc_edit = True

View file

@ -208,19 +208,17 @@ class PlayStrm(object):
''' '''
seektime = app.PLAYSTATE.resume_playback seektime = app.PLAYSTATE.resume_playback
app.PLAYSTATE.resume_playback = None app.PLAYSTATE.resume_playback = None
auto_play = utils.window('plex.autoplay.bool') if app.PLAYSTATE.autoplay:
if auto_play:
seektime = False seektime = False
LOG.info('Skip resume for autoplay') LOG.info('Skip resume for autoplay')
elif seektime is None: elif seektime is None:
resume = self.api.resume_point() resume = self.api.resume_point()
if resume: if resume:
seektime = resume_dialog(resume) seektime = resume_dialog(resume)
LOG.info('Resume: %s', seektime) LOG.info('User chose resume: %s', seektime)
if seektime is None: if seektime is None:
raise PlayStrmException('User backed out of resume dialog.') raise PlayStrmException('User backed out of resume dialog.')
# Todo: Probably need to have a look here app.PLAYSTATE.autoplay = True
utils.window('plex.autoplay.bool', value='true')
return seektime return seektime
def _set_intros(self, xml): def _set_intros(self, xml):