Fix double report progress
Removed stack implementation. Working with playlist and setresolvedurl.
This commit is contained in:
parent
9970a770c4
commit
48654801e5
2 changed files with 19 additions and 44 deletions
|
@ -77,6 +77,7 @@ class PlaybackUtils():
|
||||||
|
|
||||||
propertiesPlayback = utils.window('propertiesPlayback') == "true"
|
propertiesPlayback = utils.window('propertiesPlayback') == "true"
|
||||||
introsPlaylist = False
|
introsPlaylist = False
|
||||||
|
dummyPlaylist = False
|
||||||
currentPosition = startPos
|
currentPosition = startPos
|
||||||
|
|
||||||
self.logMsg("Playlist start position: %s" % startPos, 2)
|
self.logMsg("Playlist start position: %s" % startPos, 2)
|
||||||
|
@ -184,6 +185,7 @@ class PlaybackUtils():
|
||||||
|
|
||||||
if (not homeScreen and introsPlaylist) or (homeScreen and sizePlaylist > 0):
|
if (not homeScreen and introsPlaylist) or (homeScreen and sizePlaylist > 0):
|
||||||
# Playlist will fail on the current position. Adding dummy url
|
# Playlist will fail on the current position. Adding dummy url
|
||||||
|
dummyPlaylist = True
|
||||||
self.logMsg("Adding dummy url to counter the setResolvedUrl error.", 2)
|
self.logMsg("Adding dummy url to counter the setResolvedUrl error.", 2)
|
||||||
playlist.add(playurl, index=startPos)
|
playlist.add(playurl, index=startPos)
|
||||||
currentPosition += 1
|
currentPosition += 1
|
||||||
|
@ -194,6 +196,7 @@ class PlaybackUtils():
|
||||||
self.logMsg("Resetting properties playback flag.", 2)
|
self.logMsg("Resetting properties playback flag.", 2)
|
||||||
utils.window('propertiesPlayback', clear=True)
|
utils.window('propertiesPlayback', clear=True)
|
||||||
|
|
||||||
|
|
||||||
self.verifyPlaylist()
|
self.verifyPlaylist()
|
||||||
|
|
||||||
############### PLAYBACK ################
|
############### PLAYBACK ################
|
||||||
|
@ -203,8 +206,8 @@ class PlaybackUtils():
|
||||||
self.logMsg("Processed as a single item.", 1)
|
self.logMsg("Processed as a single item.", 1)
|
||||||
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listItem)
|
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listItem)
|
||||||
|
|
||||||
elif not homeScreen:
|
elif dummyPlaylist:
|
||||||
|
# Added a dummy file to the playlist because the first item is going to fail automatically.
|
||||||
self.logMsg("Processed as a playlist. First item is skipped.", 1)
|
self.logMsg("Processed as a playlist. First item is skipped.", 1)
|
||||||
xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, listItem)
|
xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, listItem)
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,6 @@ class Player( xbmc.Player ):
|
||||||
played_information = {}
|
played_information = {}
|
||||||
playStats = {}
|
playStats = {}
|
||||||
currentFile = None
|
currentFile = None
|
||||||
stackFiles = None
|
|
||||||
stackElapsed = 0
|
|
||||||
|
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
|
|
||||||
|
@ -47,24 +45,6 @@ class Player( xbmc.Player ):
|
||||||
def GetPlayStats(self):
|
def GetPlayStats(self):
|
||||||
return self.playStats
|
return self.playStats
|
||||||
|
|
||||||
def currentStackItem(self, stackItems):
|
|
||||||
# Only for stacked items - stack://
|
|
||||||
xbmcplayer = self.xbmcplayer
|
|
||||||
|
|
||||||
stack = stackItems.replace("stack://", "").split(" , ")
|
|
||||||
position = xbmcplayer.getTime()
|
|
||||||
totalRuntime = 0
|
|
||||||
|
|
||||||
for item in stack:
|
|
||||||
runtime = int(utils.window("%sruntimeticks" % item)) / 10000000
|
|
||||||
# Verify the position compared to the totalRuntime for stacked items processed in loop so far.
|
|
||||||
if position < (runtime + totalRuntime):
|
|
||||||
self.stackElapsed = totalRuntime
|
|
||||||
self.currentFile = item
|
|
||||||
return item
|
|
||||||
else:
|
|
||||||
totalRuntime += runtime
|
|
||||||
|
|
||||||
def onPlayBackStarted( self ):
|
def onPlayBackStarted( self ):
|
||||||
# Will be called when xbmc starts playing a file
|
# Will be called when xbmc starts playing a file
|
||||||
xbmcplayer = self.xbmcplayer
|
xbmcplayer = self.xbmcplayer
|
||||||
|
@ -73,12 +53,11 @@ class Player( xbmc.Player ):
|
||||||
# Get current file
|
# Get current file
|
||||||
try:
|
try:
|
||||||
currentFile = xbmcplayer.getPlayingFile()
|
currentFile = xbmcplayer.getPlayingFile()
|
||||||
xbmc.sleep(200)
|
xbmc.sleep(300)
|
||||||
except:
|
except:
|
||||||
currentFile = ""
|
currentFile = ""
|
||||||
count = 0
|
count = 0
|
||||||
while not currentFile:
|
while not currentFile:
|
||||||
|
|
||||||
xbmc.sleep(100)
|
xbmc.sleep(100)
|
||||||
try:
|
try:
|
||||||
currentFile = xbmcplayer.getPlayingFile()
|
currentFile = xbmcplayer.getPlayingFile()
|
||||||
|
@ -91,17 +70,8 @@ class Player( xbmc.Player ):
|
||||||
|
|
||||||
|
|
||||||
if currentFile:
|
if currentFile:
|
||||||
# if stack://, get currently playing item
|
|
||||||
if "stack://" in currentFile:
|
|
||||||
self.stackFiles = currentFile
|
|
||||||
currentFile = self.currentStackItem(currentFile)
|
|
||||||
else:
|
|
||||||
self.stackFiles = None
|
|
||||||
self.currentFile = currentFile
|
self.currentFile = currentFile
|
||||||
self.stackElapsed = 0
|
|
||||||
|
|
||||||
self.logMsg("ONPLAYBACK_STARTED: %s" % currentFile, 0)
|
|
||||||
|
|
||||||
|
|
||||||
# We may need to wait for info to be set in kodi monitor
|
# We may need to wait for info to be set in kodi monitor
|
||||||
itemId = utils.window("%sitem_id" % currentFile)
|
itemId = utils.window("%sitem_id" % currentFile)
|
||||||
|
@ -116,6 +86,8 @@ class Player( xbmc.Player ):
|
||||||
else: tryCount += 1
|
else: tryCount += 1
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
self.logMsg("ONPLAYBACK_STARTED: %s ITEMID: %s" % (currentFile, itemId), 0)
|
||||||
|
|
||||||
# Only proceed if an itemId was found.
|
# Only proceed if an itemId was found.
|
||||||
runtime = utils.window("%sruntimeticks" % currentFile)
|
runtime = utils.window("%sruntimeticks" % currentFile)
|
||||||
refresh_id = utils.window("%srefresh_id" % currentFile)
|
refresh_id = utils.window("%srefresh_id" % currentFile)
|
||||||
|
@ -143,7 +115,7 @@ class Player( xbmc.Player ):
|
||||||
'MediaSourceId': itemId,
|
'MediaSourceId': itemId,
|
||||||
'PlayMethod': playMethod,
|
'PlayMethod': playMethod,
|
||||||
'VolumeLevel': volume,
|
'VolumeLevel': volume,
|
||||||
'PositionTicks': int(seekTime * 10000000) - int(self.stackElapsed * 10000000),
|
'PositionTicks': int(seekTime * 10000000),
|
||||||
'IsMuted': muted
|
'IsMuted': muted
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,7 +197,7 @@ class Player( xbmc.Player ):
|
||||||
'SubtitleStreamIndex': postdata['SubtitleStreamIndex'],
|
'SubtitleStreamIndex': postdata['SubtitleStreamIndex'],
|
||||||
'playmethod': playMethod,
|
'playmethod': playMethod,
|
||||||
'Type': itemType,
|
'Type': itemType,
|
||||||
'currentPosition': int(seekTime) - int(self.stackElapsed)
|
'currentPosition': int(seekTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.played_information[currentFile] = data
|
self.played_information[currentFile] = data
|
||||||
|
@ -284,7 +256,7 @@ class Player( xbmc.Player ):
|
||||||
'ItemId': itemId,
|
'ItemId': itemId,
|
||||||
'MediaSourceId': itemId,
|
'MediaSourceId': itemId,
|
||||||
'PlayMethod': playMethod,
|
'PlayMethod': playMethod,
|
||||||
'PositionTicks': int(playTime * 10000000) - int(self.stackElapsed * 10000000),
|
'PositionTicks': int(playTime * 10000000),
|
||||||
'IsPaused': paused,
|
'IsPaused': paused,
|
||||||
'VolumeLevel': volume,
|
'VolumeLevel': volume,
|
||||||
'IsMuted': muted
|
'IsMuted': muted
|
||||||
|
@ -432,7 +404,7 @@ class Player( xbmc.Player ):
|
||||||
|
|
||||||
if percentComplete >= markPlayedAt and offerDelete:
|
if percentComplete >= markPlayedAt and offerDelete:
|
||||||
# Item could be stacked, so only offer to delete the main item.
|
# Item could be stacked, so only offer to delete the main item.
|
||||||
if not self.stackFiles or itemId == utils.window('%sitem_id' % self.stackFiles):
|
self.logMsg("Offering deletion for: %s." % itemId, 1)
|
||||||
return_value = xbmcgui.Dialog().yesno("Offer Delete", "Delete %s" % currentFile.split("/")[-1], "on Emby Server?")
|
return_value = xbmcgui.Dialog().yesno("Offer Delete", "Delete %s" % currentFile.split("/")[-1], "on Emby Server?")
|
||||||
if return_value:
|
if return_value:
|
||||||
# Delete Kodi entry before Emby
|
# Delete Kodi entry before Emby
|
||||||
|
|
Loading…
Reference in a new issue