Support resume default action

This commit is contained in:
angelblue05 2018-05-10 20:24:59 -05:00
parent 20b2061f4f
commit 76a29d2039

View file

@ -26,7 +26,7 @@ import shutil
import embydb_functions as embydb import embydb_functions as embydb
from database import DatabaseConn from database import DatabaseConn
from dialogs import resume from dialogs import resume
from utils import window, settings, language as lang from utils import window, settings, language as lang, JSONRPC
################################################################################################# #################################################################################################
@ -90,7 +90,7 @@ class PlaybackUtils(object):
listitem = xbmcgui.ListItem() listitem = xbmcgui.ListItem()
log.info("Play called: %s", self.item['Name']) log.info("Play called %s: %s", item_id, self.item['Name'])
resume = window('emby.resume') resume = window('emby.resume')
window('emby.resume', clear=True) window('emby.resume', clear=True)
@ -102,17 +102,27 @@ class PlaybackUtils(object):
self.playlist.clear() self.playlist.clear()
return xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, listitem) return xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, listitem)
if force_transcode:
seektime = self.API.get_userdata()['Resume'] if self.item['Type'] != "Audio":
if seektime:
resume = self.resume_dialog(seektime) ''' Detect the seektime for video type content.
if resume is None: Verify the default video action set in Kodi for accurate resume behavior.
return xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, listitem) '''
elif not resume: if self.get_play_action() == "Resume":
seektime = 0 resume = "true"
else:
seektime = self.API.adjust_resume(self.API.get_userdata()['Resume']) if resume == "true" else 0 if force_transcode:
seektime = self.API.get_userdata()['Resume']
if seektime and resume != "true":
resume = self.resume_dialog(seektime)
if resume is None:
return xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, listitem)
elif not resume:
seektime = 0
else:
seektime = self.API.adjust_resume(self.API.get_userdata()['Resume']) if resume == "true" else 0
if force_transcode: if force_transcode:
log.info("Clear the playlist.") log.info("Clear the playlist.")
@ -161,9 +171,24 @@ class PlaybackUtils(object):
index += 1 index += 1
if force_play: if force_play:
if len(sys.argv) > 1: xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, self.stack[0][1]) if len(sys.argv) > 1:
xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, self.stack[0][1])
xbmc.Player().play(self.playlist, windowed=False) xbmc.Player().play(self.playlist, windowed=False)
@classmethod
def get_play_action(cls):
''' I could not figure out a way to listen to kodi setting changes?
For now, verify the play action every time play is called.
'''
options = ['Choose', 'Play', 'Resume', 'Show information']
result = JSONRPC('Settings.GetSettingValue').execute({'setting': "myvideos.selectaction"})
try:
return options[result['result']['value']]
except Exception as error:
log.error("Returning play action due to error: %s", error)
return options[1]
def set_playlist(self, play_url, item_id, listitem, seektime=None, db_id=None): def set_playlist(self, play_url, item_id, listitem, seektime=None, db_id=None):