spam throttling for time-pos

master
Dario Ernst 9 years ago
parent 65a4618c2a
commit 40b6115ee1

@ -78,13 +78,16 @@ class MpvSockParser(object):
self.processCommand(data)
def processEvent(self, data):
sendNotify = False
sendNotify = True
if "data" in data and data["data"]==None:
return
print data
if data['event'] == 'property-change' and data['name'] == 'time-pos':
self.playerState['currentDuration'] = int(data['data'])
oldCur = self.playerState['currentDuration']
curCur = int(data['data'])
if curCur - oldCur < 1:
sendNotify = False
self.playerState['currentDuration'] = curCur
if data['event'] == 'property-change' and data['name'] == 'volume':
self.playerState['volume'] = int(data['data'])
if data['event'] == 'property-change' and data['name'] == 'filename':
@ -96,27 +99,22 @@ class MpvSockParser(object):
if data['event'] == 'unpause':
self.playerState['isPlaying'] = True
print self.playerState
self.notifyListeners()
if sendNotify:
print self.playerState
self.notifyListeners()
def processCommand(self, data):
pass
def sendCommand(self, command):
print "sending command %s"%command
if command["command"] == "play":
self.poller.sendData(
'{ "command": ["set_property", "pause", true] }'
)
self.poller.sendData('{ "command": ["set_property", "pause", true] }')
if command["command"] == "pause":
self.poller.sendData(
'{ "command": ["set_property", "pause", false] }'
)
self.poller.sendData('{ "command": ["set_property", "pause", false] }')
class WSHandler(WebSocket):
def handleMessage(self):
global mpvParser
command = json.loads(self.data)
print "got command %s"%(command)
mpvParser.sendCommand(command)
self.sendMessage('{"null":""}')
def handleConnected(self):

Loading…
Cancel
Save