Pass resume point back to PMS

This commit is contained in:
tomkat83 2016-01-12 13:57:26 +01:00
parent 4c54a7c319
commit ca731ba41e
4 changed files with 46 additions and 25 deletions

View file

@ -1916,7 +1916,7 @@ class API():
def getExtras(self): def getExtras(self):
""" """
Returns a list of trailer and extras from PMS XML. Returns None if Returns a list of trailer and extras from PMS XML. Returns [] if
no extras are found. no extras are found.
Extratypes: Extratypes:
'1': Trailer '1': Trailer
@ -1932,9 +1932,9 @@ class API():
'year': 'year':
""" """
extras = self.item[0].find('Extras') extras = self.item[0].find('Extras')
if not extras:
return None
elements = [] elements = []
if not extras:
return elements
for extra in extras: for extra in extras:
# Trailer: # Trailer:
key = extra.attrib['key'] key = extra.attrib['key']

View file

@ -327,8 +327,8 @@ class DownloadUtils():
self.logMsg("Received an XML response for: %s" % url, 2) self.logMsg("Received an XML response for: %s" % url, 2)
return r return r
except: except:
self.logMsg("Unable to convert the response for: %s" % url, 1) self.logMsg("Unable to convert the response for: %s" % url, 2)
self.logMsg("Content-type was: %s" % r.headers['content-type'], 1) self.logMsg("Content-type was: %s" % r.headers['content-type'], 2)
else: else:
r.raise_for_status() r.raise_for_status()

View file

@ -352,14 +352,13 @@ class Movies(Items):
# Find one trailer # Find one trailer
trailer = None trailer = None
extras = API.getExtras() extras = API.getExtras()
if extras: for item in extras:
for item in extras: # Only get 1st trailer element
# Only get 1st trailer element if item['extraType'] == '1':
if item['extraType'] == '1': trailer = item['key']
trailer = item['key'] trailer = "plugin://plugin.video.plexkodiconnect/trailer/?id=%s&mode=play" % trailer
trailer = "plugin://plugin.video.plexkodiconnect/trailer/?id=%s&mode=play" % trailer self.logMsg("Trailer for %s: %s" % (itemid, trailer), 2)
self.logMsg("Trailer for %s: %s" % (itemid, trailer), 2) break
break
##### GET THE FILE AND PATH ##### ##### GET THE FILE AND PATH #####
playurl = API.getFilePath() playurl = API.getFilePath()

View file

@ -13,6 +13,8 @@ import downloadutils
import kodidb_functions as kodidb import kodidb_functions as kodidb
import websocket_client as wsc import websocket_client as wsc
from urllib import urlencode
################################################################################################# #################################################################################################
@ -260,6 +262,7 @@ class Player(xbmc.Player):
playTime = data['currentPosition'] playTime = data['currentPosition']
playMethod = data['playmethod'] playMethod = data['playmethod']
paused = data.get('paused', False) paused = data.get('paused', False)
duration = data.get('runtime', '')
# Get playback volume # Get playback volume
@ -281,17 +284,29 @@ class Player(xbmc.Player):
muted = result.get('muted') muted = result.get('muted')
# Postdata for the websocketclient report # Postdata for the websocketclient report
postdata = { # postdata = {
'QueueableMediaTypes': "Video", # 'QueueableMediaTypes': "Video",
'CanSeek': True, # 'CanSeek': True,
'ItemId': itemId, # 'ItemId': itemId,
'MediaSourceId': itemId, # 'MediaSourceId': itemId,
'PlayMethod': playMethod, # 'PlayMethod': playMethod,
'PositionTicks': int(playTime * 10000000), # 'PositionTicks': int(playTime * 10000000),
'IsPaused': paused, # 'IsPaused': paused,
'VolumeLevel': volume, # 'VolumeLevel': volume,
'IsMuted': muted # 'IsMuted': muted
# }
if paused == 'stopped':
state = 'stopped'
elif paused == 'True':
state = 'paused'
else:
state = 'playing'
postdata = {
'ratingKey': itemId,
'state': state, # 'stopped', 'paused', 'buffering', 'playing'
'time': int(playTime) * 1000,
'duration': int(duration) * 1000
} }
if playMethod == "Transcode": if playMethod == "Transcode":
@ -362,9 +377,11 @@ class Player(xbmc.Player):
data['SubtitleStreamIndex'], postdata['SubtitleStreamIndex'] = [""] * 2 data['SubtitleStreamIndex'], postdata['SubtitleStreamIndex'] = [""] * 2
# Report progress via websocketclient # Report progress via websocketclient
postdata = json.dumps(postdata) # postdata = json.dumps(postdata)
self.logMsg("Report: %s" % postdata, 2) self.logMsg("Report: %s" % postdata, 2)
self.ws.sendProgressUpdate(postdata) # self.ws.sendProgressUpdate(postdata)
url = "{server}/:/timeline?" + urlencode(postdata)
self.doUtils.downloadUrl(url, type="GET")
def onPlayBackPaused( self ): def onPlayBackPaused( self ):
@ -399,7 +416,12 @@ class Player(xbmc.Player):
def onPlayBackStopped( self ): def onPlayBackStopped( self ):
# Will be called when user stops xbmc playing a file # Will be called when user stops xbmc playing a file
currentFile = self.currentFile
self.logMsg("ONPLAYBACK_STOPPED", 2) self.logMsg("ONPLAYBACK_STOPPED", 2)
if self.played_info.get(currentFile):
self.played_info[currentFile]['paused'] = 'stopped'
self.reportPlayback()
xbmcgui.Window(10101).clearProperties() xbmcgui.Window(10101).clearProperties()
self.logMsg("Clear playlist properties.") self.logMsg("Clear playlist properties.")
self.stopAll() self.stopAll()