Correctly tell PMS when we stopped playing
This commit is contained in:
parent
0315773009
commit
5be7d835f8
1 changed files with 38 additions and 20 deletions
|
@ -16,6 +16,12 @@ class SubscriptionManager:
|
||||||
self.lastkey = ""
|
self.lastkey = ""
|
||||||
self.containerKey = ""
|
self.containerKey = ""
|
||||||
self.ratingkey = ""
|
self.ratingkey = ""
|
||||||
|
self.lastplayers = {}
|
||||||
|
self.lastinfo = {
|
||||||
|
'video': {},
|
||||||
|
'audio': {},
|
||||||
|
'picture': {}
|
||||||
|
}
|
||||||
self.volume = 0
|
self.volume = 0
|
||||||
self.mute = '0'
|
self.mute = '0'
|
||||||
self.server = ""
|
self.server = ""
|
||||||
|
@ -147,31 +153,43 @@ class SubscriptionManager:
|
||||||
for sub in self.subscribers.values():
|
for sub in self.subscribers.values():
|
||||||
sub.send_update(msg, len(players) == 0)
|
sub.send_update(msg, len(players) == 0)
|
||||||
self.notifyServer(players)
|
self.notifyServer(players)
|
||||||
|
self.lastplayers = players
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def notifyServer(self, players):
|
def notifyServer(self, players):
|
||||||
for p in players.values():
|
for typus, p in players.iteritems():
|
||||||
info = self.playerprops[p.get('playerid')]
|
info = self.playerprops[p.get('playerid')]
|
||||||
params = {'state': 'stopped'}
|
self._sendNotification(info)
|
||||||
params['containerKey'] = (self.containerKey or "/library/metadata/900000")
|
self.lastinfo[typus] = info
|
||||||
if info.get('playQueueID'):
|
# Cross the one of the list
|
||||||
params['containerKey'] = '/playQueues/' + info['playQueueID']
|
try:
|
||||||
params['playQueueVersion'] = info['playQueueVersion']
|
del self.lastplayers[typus]
|
||||||
params['playQueueItemID'] = info['playQueueItemID']
|
except KeyError:
|
||||||
params['key'] = (self.lastkey or "/library/metadata/900000")
|
pass
|
||||||
params['ratingKey'] = (self.ratingkey or "900000")
|
# Process the players we have left (to signal a stop)
|
||||||
params['state'] = info['state']
|
for typus, p in self.lastplayers.iteritems():
|
||||||
params['time'] = info['time']
|
self._sendNotification(self.lastinfo[typus])
|
||||||
params['duration'] = info['duration']
|
|
||||||
|
|
||||||
serv = self.getServerByHost(self.server)
|
def _sendNotification(self, info):
|
||||||
url = serv.get('protocol', 'http') + '://' \
|
params = {
|
||||||
+ serv.get('server', 'localhost') + ':' \
|
'containerKey': self.containerKey or "/library/metadata/900000",
|
||||||
+ serv.get('port', '32400') + "/:/timeline"
|
'key': self.lastkey or "/library/metadata/900000",
|
||||||
self.doUtils(url, parameters=params)
|
'ratingKey': self.ratingkey or "900000",
|
||||||
# requests.getwithparams(serv.get('server', 'localhost'), serv.get('port', 32400), "/:/timeline", params, getPlexHeaders(), serv.get('protocol', 'http'))
|
'state': info['state'],
|
||||||
self.logMsg("sent server notification with parameters: %s"
|
'time': info['time'],
|
||||||
% params, 2)
|
'duration': info['duration']
|
||||||
|
}
|
||||||
|
if info.get('playQueueID'):
|
||||||
|
params['containerKey'] = '/playQueues/%s' % info['playQueueID']
|
||||||
|
params['playQueueVersion'] = info['playQueueVersion']
|
||||||
|
params['playQueueItemID'] = info['playQueueItemID']
|
||||||
|
serv = self.getServerByHost(self.server)
|
||||||
|
url = '%s://%s:%s/:/timeline' % (serv.get('protocol', 'http'),
|
||||||
|
serv.get('server', 'localhost'),
|
||||||
|
serv.get('port', '32400'))
|
||||||
|
self.doUtils(url, parameters=params)
|
||||||
|
self.logMsg("Sent server notification with parameters: %s to %s"
|
||||||
|
% (params, url), 2)
|
||||||
|
|
||||||
def controllable(self):
|
def controllable(self):
|
||||||
return "volume,shuffle,repeat,audioStream,videoStream,subtitleStream,skipPrevious,skipNext,seekTo,stepBack,stepForward,stop,playPause"
|
return "volume,shuffle,repeat,audioStream,videoStream,subtitleStream,skipPrevious,skipNext,seekTo,stepBack,stepForward,stop,playPause"
|
||||||
|
|
Loading…
Reference in a new issue