Resume revert

Instead of seeking to position, now using setProperty('StartOffset') to
launch playback at the position we want.
This commit is contained in:
angelblue05 2015-07-19 23:25:59 -05:00
parent 4e7cbc56ba
commit 1cda4ac30e
2 changed files with 28 additions and 70 deletions

View file

@ -49,8 +49,14 @@ class PlaybackUtils():
return return
userData = result['UserData'] userData = result['UserData']
resume_result = 0
seekTime = 0 # BOOKMARK - RESUME POINT
timeInfo = API().getTimeInfo(result)
jumpBackSec = int(addon.getSetting("resumeJumpBack"))
seekTime = round(float(timeInfo.get('ResumeTime')), 6)
if seekTime > jumpBackSec:
# To avoid negative bookmark
seekTime = seekTime - jumpBackSec
if userData.get("PlaybackPositionTicks") != 0: if userData.get("PlaybackPositionTicks") != 0:
reasonableTicks = int(userData.get("PlaybackPositionTicks")) / 1000 reasonableTicks = int(userData.get("PlaybackPositionTicks")) / 1000
@ -118,6 +124,21 @@ class PlaybackUtils():
WINDOW.setProperty(playurl+"deleteurl", "") WINDOW.setProperty(playurl+"deleteurl", "")
WINDOW.setProperty(playurl+"deleteurl", deleteurl) WINDOW.setProperty(playurl+"deleteurl", deleteurl)
#show the additional resume dialog if launched from a widget
if xbmc.getCondVisibility("Window.IsActive(home)"):
if seekTime != 0:
displayTime = str(datetime.timedelta(seconds=(int(seekTime))))
display_list = [ self.language(30106) + ' ' + displayTime, self.language(30107)]
resumeScreen = xbmcgui.Dialog()
resume_result = resumeScreen.select(self.language(30105), display_list)
if resume_result == 0:
listItem.setProperty('StartOffset', str(seekTime))
elif resume_result < 0:
# User cancelled dialog
xbmc.log("Emby player -> User cancelled resume dialog.")
return
if result.get("Type")=="Episode": if result.get("Type")=="Episode":
WINDOW.setProperty(playurl+"refresh_id", result.get("SeriesId")) WINDOW.setProperty(playurl+"refresh_id", result.get("SeriesId"))
else: else:
@ -148,7 +169,11 @@ class PlaybackUtils():
self.setListItemProps(server, id, listItem, result) self.setListItemProps(server, id, listItem, result)
xbmc.Player().play(playurl,listItem) xbmc.Player().play(playurl,listItem)
elif setup == "default": elif setup == "default":
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listItem) if xbmc.getCondVisibility("Window.IsActive(home)"):
self.setListItemProps(server, id, listItem, result)
xbmc.Player().play(playurl,listItem)
else:
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listItem)
def setArt(self, list,name,path): def setArt(self, list,name,path):
if name=='thumb' or name=='fanart_image' or name=='small_poster' or name=='tiny_poster' or name == "medium_landscape" or name=='medium_poster' or name=='small_fanartimage' or name=='medium_fanartimage' or name=='fanart_noindicators': if name=='thumb' or name=='fanart_image' or name=='small_poster' or name=='tiny_poster' or name == "medium_landscape" or name=='medium_poster' or name=='small_fanartimage' or name=='medium_fanartimage' or name=='fanart_noindicators':

View file

@ -253,39 +253,6 @@ class WriteKodiVideoDB():
resume = resume - jumpback resume = resume - jumpback
self.setKodiResumePoint(fileid, resume, total, cursor) self.setKodiResumePoint(fileid, resume, total, cursor)
# Create a dummy bookmark for homescreen - widgets
if not self.directpath:
plugindummy = "plugin://plugin.video.emby/"
cursor.execute("SELECT idPath as pathid FROM path WHERE strPath = ?", (plugindummy,))
try:
pathid = cursor.fetchone()[0]
except:
# Top level path does not exist yet
cursor.execute("select coalesce(max(idPath),0) as tlpathid from path")
pathid = cursor.fetchone()[0] + 1
query = "INSERT INTO path(idPath, strPath, strContent, strScraper, noUpdate) values(?, ?, ?, ?, ?)"
cursor.execute(query, (pathid, plugindummy, "tvshows", "metadata.local", 1))
# Validate the file in database
cursor.execute("SELECT idFile as fileid FROM files WHERE strFilename = ? and idPath = ?", (filename, pathid,))
try:
fileid = cursor.fetchone()[0]
except:
# File does not exist yet
if resume:
cursor.execute("select coalesce(max(idFile),0) as fileid from files")
fileid = cursor.fetchone()[0] + 1
query = "INSERT INTO files(idFile, idPath, strFilename, playCount, lastPlayed, dateAdded) values(?, ?, ?, ?, ?, ?)"
cursor.execute(query, (fileid, pathid, filename, playcount, dateplayed, dateadded))
self.setKodiResumePoint(fileid, resume, total, cursor)
else: # File exists
if not resume:
cursor.execute("DELETE FROM files WHERE idFile = ?", (fileid,))
else:
query = "UPDATE files SET playCount = ?, lastPlayed = ? WHERE idFile = ?"
cursor.execute(query, (playcount, dateplayed, fileid))
self.setKodiResumePoint(fileid, resume, total, cursor)
def addOrUpdateMusicVideoToKodiLibrary(self, embyId ,connection, cursor): def addOrUpdateMusicVideoToKodiLibrary(self, embyId ,connection, cursor):
addon = self.addon addon = self.addon
@ -700,40 +667,6 @@ class WriteKodiVideoDB():
resume = resume - jumpback resume = resume - jumpback
self.setKodiResumePoint(fileid, resume, total, cursor) self.setKodiResumePoint(fileid, resume, total, cursor)
if not self.directpath:
# Create a dummy bookmark for homescreen - widgets
plugindummy = "plugin://plugin.video.emby/"
cursor.execute("SELECT idPath as pathid FROM path WHERE strPath = ?", (plugindummy,))
try:
pathid = cursor.fetchone()[0]
except:
# Top level path does not exist yet
cursor.execute("select coalesce(max(idPath),0) as tlpathid from path")
pathid = cursor.fetchone()[0] + 1
query = "INSERT INTO path(idPath, strPath, strContent, strScraper, noUpdate) values(?, ?, ?, ?, ?)"
cursor.execute(query, (pathid, plugindummy, "tvshows", "metadata.local", 1))
# Validate the file in database
cursor.execute("SELECT idFile as fileid FROM files WHERE strFilename = ? and idPath = ?", (filename, pathid,))
try:
fileid = cursor.fetchone()[0]
except:
# File does not exist yet
if resume:
cursor.execute("select coalesce(max(idFile),0) as fileid from files")
fileid = cursor.fetchone()[0] + 1
query = "INSERT INTO files(idFile, idPath, strFilename, playCount, lastPlayed, dateAdded) values(?, ?, ?, ?, ?, ?)"
cursor.execute(query, (fileid, pathid, filename, playcount, dateplayed, dateadded))
self.setKodiResumePoint(fileid, resume, total, cursor)
else: # File exists
if not resume:
cursor.execute("DELETE FROM files WHERE idFile = ?", (fileid,))
else:
query = "UPDATE files SET playCount = ?, lastPlayed = ? WHERE idFile = ?"
cursor.execute(query, (playcount, dateplayed, fileid))
self.setKodiResumePoint(fileid, resume, total, cursor)
def deleteItemFromKodiLibrary(self, id, connection, cursor ): def deleteItemFromKodiLibrary(self, id, connection, cursor ):
cursor.execute("SELECT kodi_id, media_type FROM emby WHERE emby_id = ?", (id,)) cursor.execute("SELECT kodi_id, media_type FROM emby WHERE emby_id = ?", (id,))