|
|
|
|
@ -65,6 +65,8 @@ class MpvSockParser(object):
|
|
|
|
|
self.poller.sendData('{"command":["observe_property",2,"volume"]}')
|
|
|
|
|
self.poller.sendData('{"command":["observe_property",3,"filename"]}')
|
|
|
|
|
self.poller.sendData('{"command":["observe_property",4,"duration"]}')
|
|
|
|
|
self.poller.sendData('{"command":["observe_property",4,"duration"]}')
|
|
|
|
|
self.poller.sendData('{ "command": ["get_property", "pause"], "request_id":10}')
|
|
|
|
|
|
|
|
|
|
self.poller.start()
|
|
|
|
|
|
|
|
|
|
@ -104,19 +106,32 @@ class MpvSockParser(object):
|
|
|
|
|
self.notifyListeners()
|
|
|
|
|
|
|
|
|
|
def processCommand(self, data):
|
|
|
|
|
pass
|
|
|
|
|
if "request_id" in data and data['request_id'] == 10:
|
|
|
|
|
print 'synced pause state'
|
|
|
|
|
self.playerState['isPlaying'] = not data["data"]
|
|
|
|
|
|
|
|
|
|
def sendCommand(self, command):
|
|
|
|
|
if command["command"] == "play":
|
|
|
|
|
self.poller.sendData('{ "command": ["set_property", "pause", true] }')
|
|
|
|
|
if command["command"] == "pause":
|
|
|
|
|
self.poller.sendData('{ "command": ["set_property", "pause", false] }')
|
|
|
|
|
if command["command"] == "pause":
|
|
|
|
|
self.poller.sendData('{ "command": ["set_property", "pause", true] }')
|
|
|
|
|
if command["command"] == "seek":
|
|
|
|
|
self.poller.sendData('{ "command": ["seek", "%s", "absolute"] }'%command['seekValue'])
|
|
|
|
|
if command["command"] == "volume":
|
|
|
|
|
self.poller.sendData('{ "command": ["set", "volume", %s] }'%command['volume'])
|
|
|
|
|
if command["command"] == "seekChapter":
|
|
|
|
|
if command['direction'] == 'forward':
|
|
|
|
|
direction = +1
|
|
|
|
|
elif command['direction'] == 'backward':
|
|
|
|
|
direction = -1
|
|
|
|
|
self.poller.sendData('{ "command": ["add", "chapter", %s] }'%direction)
|
|
|
|
|
|
|
|
|
|
class WSHandler(WebSocket):
|
|
|
|
|
def handleMessage(self):
|
|
|
|
|
global mpvParser
|
|
|
|
|
command = json.loads(self.data)
|
|
|
|
|
print 'got commadn %s'%command
|
|
|
|
|
mpvParser.sendCommand(command)
|
|
|
|
|
self.sendMessage('{"null":""}')
|
|
|
|
|
def handleConnected(self):
|
|
|
|
|
global mpvParser
|
|
|
|
|
mpvParser.registerListener(self)
|
|
|
|
|
|